I would like to run program in guest OS.
Version: vSphere web service SDK 7.0
Language: C#
I do not know how to new a instance to invoke StartProgramInGuest. Could someone help me? I would appreicate you very much.
My program will have an error when executed to line "var vimPortType = new VimPortTypeClient("StartInGuest", @"https://localhost/sdk/vimService");"
code ##############################################################
using System;
using Vim25Api;
other code ...
public static void StartInGuest()
{
ManagedObjectReference processMgr = new ManagedObjectReference();
processMgr.type = "GuestProcessManager";
processMgr.Value = "ha-guest-operations-process-manager";
NamePasswordAuthentication auth = new NamePasswordAuthentication();
auth.username = "zzz";
auth.password = "123";
auth.interactiveSession = true;
GuestProgramSpec progSpec = new GuestProgramSpec();
progSpec.programPath = "C:\\WINDOWS\\NOTEPAD.EXE";
progSpec.arguments = "";
var vmRef = new ManagedObjectReference { type = "VirtualMachine", Value = "vm-192" };
VirtualMachineGuestQuiesceSpec virtualMachineGuestQuiesceSpec = new VirtualMachineGuestQuiesceSpec();
var vimPortType = new VimPortTypeClient("StartInGuest", @"https://localhost/sdk/vimService");
try
{
long pid = vimPortType.StartProgramInGuest(processMgr, vmRef, auth, progSpec);
}
catch (System.Web.Services.Protocols.SoapException se)
{
Console.WriteLine(se.Message);
Console.WriteLine(se.Detail.FirstChild.LocalName);
}
catch (Exception ex)
{
Console.WriteLine(ex);
}
}
Moderator: Moved to the vSphere Guest SDK Discussions area (the closest I can see to the Web Service SDK) - this thread needs to be in the {code} area.