You are on page 1of 1

Dim objWMIService, objProcess

Dim strShell, objProgram, strExe

strComputer = "10.0.10.189"

'strExe = "\\servername\share\folder\install\setup.EXE"
strExe = "explorer.exe \\servername\share\folder\install\setup.EXE"

'that works

'strExe = "calc.exe"

' Connect to WMI

Set objWMIService = GetObject("winmgmts:\\" & strComputer &


"\root\cimv2:Win32_Process")

'set objWMIService = getobject("winmgmts://" & strComputer & "/root/cimv2")

If Err <> 0 Then

WScript.Echo "Error connecting to WMI on \\" & strComputer & "."

WScript.Echo "Error number: " & Err.Number

WScript.Echo "Error source: " & Err.Source

WScript.Echo "Error description: " & Err.Description

Error.Clear

Exit Function

End If

' Obtain the Win32_Process class of object.

Set objProcess = objWMIService.Get("Win32_Process")

Set objProgram = objProcess.Methods_( _

"Create").InParameters.SpawnInstance_

objProgram.CommandLine = strExe

'Execute the program now at the command line.

Set strShell = objWMIService.ExecMethod( _

"Win32_Process", "Create", objProgram)

WScript.echo "Created: " & strExe & " on " & strComputer

You might also like