Hi all,
I search the all examples from Java and C# about this function usage. However, I always get the exception
"The object 'vim.vm.guest.ProcessManager:guestOperationsProcessManager' has already been deleted or has not been completely created" VMware.Vim.VimException. |
Could someone help it?
NameValueCollection nvcFilter = new NameValueCollection();
nvcFilter.Add("Name", "W81x64");
_vm = (VirtualMachine)_client.FindEntityView(typeof(VirtualMachine), null, nvcFilter, null);
while (true)
{
_vm.UpdateViewData();
if (_vm.Guest.ToolsStatus == VirtualMachineToolsStatus.toolsOk)
{
break;
}
Thread.Sleep(3000);
}
NamePasswordAuthentication auth = new NamePasswordAuthentication();
auth.Password = "admin";
auth.Username = "password";
auth.InteractiveSession = false;
ManagedObjectReference vmRef = new ManagedObjectReference ();
vmRef.Type = "VirtualMachine";
vmRef.Value = "W81x64";
GuestWindowsProgramSpec progSpec = new GuestWindowsProgramSpec();
progSpec.Arguments = "";
progSpec.ProgramPath = @"C:\Windows\system32\calc.exe";
ManagedObjectReference moRf= new ManagedObjectReference();
moRf.Type = "GuestProcessManager";
moRf.Value = "guestOperationsProcessManager";
GuestProcessManager guestprogmgr = new GuestProcessManager(VimClient,moRf);
long pid = guestprogmgr.StartProgramInGuest(vmRef, auth, progSpec);
It's not a direct reply to your question, but the following works for me.
Consider it PowerShell prototyping :smileygrin:
$vmName = 'MyVM'
$vm = Get-VM -Name $vmName
$si = Get-View ServiceInstance
$opMgr = Get-View -Id $si.Content.guestOperationsManager
$spec = New-Object VMware.Vim.NamePasswordAuthentication
$spec.UserName = 'domain\user'
$spec.Password = 'password'
$spec.interactiveSession = $false
$procMgr = Get-View $opMgr.ProcessManager
$prog = New-Object VMware.Vim.GuestWindowsProgramSpec$prog.ProgramPath = 'C:\Windows\System32\notepad.exe'
$prog.arguments = ''
$prog.StartMinimized = $false
$procMgr.StartProgramInGuest($vm.ExtensionData.MoRef,$spec,$prog)
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
It's not a direct reply to your question, but the following works for me.
Consider it PowerShell prototyping :smileygrin:
$vmName = 'MyVM'
$vm = Get-VM -Name $vmName
$si = Get-View ServiceInstance
$opMgr = Get-View -Id $si.Content.guestOperationsManager
$spec = New-Object VMware.Vim.NamePasswordAuthentication
$spec.UserName = 'domain\user'
$spec.Password = 'password'
$spec.interactiveSession = $false
$procMgr = Get-View $opMgr.ProcessManager
$prog = New-Object VMware.Vim.GuestWindowsProgramSpec$prog.ProgramPath = 'C:\Windows\System32\notepad.exe'
$prog.arguments = ''
$prog.StartMinimized = $false
$procMgr.StartProgramInGuest($vm.ExtensionData.MoRef,$spec,$prog)
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi LucD,
Thanks for your information.
I found the bug of the program because your command.