Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
Keywords: Run Launch Application Program Process Remote Computer Machine RPC Remote Procedure Call
For security reasons the Win32_Process.Create method cannot be used to start an interactive process.
;*************************************************************************** ;** RunRemote(ComputerName,Application,WorkingDir,UserName,Password) ;** Runs an application on a remote computer. ;** ;** Parameters: ;** ComputerName: Computer name without \\, and "" for local. ;** Application: Program to run. Can include full path or UNC. Can also include Parameters. ;** WorkingDir: Working Directory for program or "" for default. ;** UserName: User name to run program as ;** In format DOMAIN\User or just User for local, "" for current user running script. ;** MUST be "" for local computer or the function will fail. ;** Password: Password for user or "" if username is "". ;** ;** Returns: ;** Result: the result of the create call. ;** Value Meaning ;** 0 Successful completion ;** 2 Access denied ;** 3 Insufficient privilege ;** 8 Unknown failure ;** 9 Path not found ;** 21 Invalid parameter ;** ;** !!!!!!! NOTES !!!!!!!!! ;** If the newly created process attempts to interact with objects on the target system without ;** appropriate access privileges, it is terminated without notification to this method. ;** ;** Note The Win32_Process.Create method cannot be used to start an interactive process for security reasons. ;** ;*************************************************************************** #DefineFunction RunRemote(ComputerName,Application,WorkingDirectory,User,Password) Locator = ObjectOpen("WbemScripting.SWbemLocator") Service = Locator.ConnectServer(ComputerName,"root/cimv2",User,Password) Security = Service.Security_ Security.ImpersonationLevel = 3 Class = Service.Get("Win32_Process") If WorkingDirectory == "" then Result = Class.Create(Application) ;no working directory specified Else Result = Class.Create(Application,WorkingDirectory) ;pass the specified working directory EndIf ObjectClose(Class) ObjectClose(Security) ObjectClose(Service) ObjectClose(Locator) Return Result #EndFunction ComputerName = "SCOOBY" ;remote machine name (specify "" for local machine) Application = "Notepad.exe" WorkDir = "" User = "" Password = "" rslt = RunRemote(ComputerName,Application,WorkDir,User,Password) Switch rslt Case 0 Message("RunRemote","Successful completion ") break Case 2 Message("RunRemote","Access denied") break Case 3 Message("RunRemote","Insufficient privilege") break Case 8 Message("RunRemote","Unknown failure") break Case 9 Message("RunRemote","Path not found") break Case 21 Message("RunRemote","Invalid parameter") break Case rslt Message("RunRemote","Unknown error") break EndSwitch exit
Article ID: W15362
File Created: 2012:10:03:11:15:30
Last Updated: 2012:10:03:11:15:30