Welcome to MSDN Blogs Sign in | Join | Help

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 & "\root\cimv2: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 & "."
Else
    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: http://blogs.msdn.com/virtual_pc_guy/archive/2006/03/02/541124.aspx

Cheers,
Ben

Published Thursday, June 01, 2006 7:56 PM by Virtual PC Guy

Comments

Tuesday, June 20, 2006 11:46 AM by Arturo Matos

# re: Launching programs remotely via WMI

Hi, Ben, your work it's great...congratulations

I'm new with the Virtual PC and the MS environment (I'm a basic Linux user).
So, maybe my question sound like a dummy-issue :).. anyway..

¿ How I can execute this code? Cutting & paste over the Visual Basic ide ? Visual Studio C, c++ ? #C ? .Net ? because from a *.cmd or *.bat impossible.

Thanks for your help !
Arturo
arturo.matos@gmail.com



Tuesday, June 20, 2006 5:31 PM by DJ - Overwhelmed Intern

# re: Launching programs remotely via WMI

Arturo,

I'm pretty new to this stuff too, and was also confused at first.  It's just a snippet of VBscript code.

I'm guessing you'll soon be seeing a lot of these :)
New Comments to this post are disabled
 
Page view tracker