Launching programs remotely via WMI

One thing that people regularly ask how to do with Virtual Server / Virtual PC is to be able to remotely, programmatically start a program running inside of a virtual machine.  We do not provide anyway to do this directly with our products – however you can do this by using the built in support in Windows.  The following script will open a copy of notepad on a remote computer:

strComputer = “NameOrIPAdressOfVirtualMachine”
Set objWMIService = GetObject(“winmgmts:” _
    & “{impersonationLevel=impersonate}!\” & strComputer & “rootcimv2:Win32_Process”)

Error = objWMIService.Create(“notepad.exe”, null, null, intProcessID)
If Error = 0 Then
    Wscript.Echo “Notepad was started with a process ID of ” _
         & intProcessID & “.”
    Wscript.Echo “Notepad could not be started due to error ” & _
        Error & “.”
End If

In order to do this you will need to follow the same network configuration as discussed in this article: