InvokeMethod ????????????
-
I am doing following to run a remote-machine's process on that remote-machine: ConnectionOptions objConnectionOptions = new ConnectionOptions(); objConnectionOptions.Impersonation = ImpersonationLevel.Impersonate; objConnectionOptions.EnablePrivileges = true; objConnectionOptions.Username = strUserName; objConnectionOptions.Password = strPassword; ManagementScope objManagementScope = new ManagementScope(@"\\remote-machine-name\ROOT\CIMV2", objConnectionOptions); objManagementScope.Connect(); ManagementClass processClassFinal = new ManagementClass(objManagementScope, new ManagementPath("Win32_Process"), null); ManagementBaseObject inParamsFinal = processClassFinal.GetMethodParameters("Create"); inParamsFinal["CommandLine"] = @"\\remote-machine-name\some-directory\someProgram.exe"; ManagementBaseObject outParamsFinal = processClassFinal.InvokeMethod("Create", inParamsFinal, null); But for some reason it does not work and I don't know why??????? outParamsFinal["processId"] returns null, instead of a valid processId. Is there any one who could help me in that.............. Thanks Sarfraz
-
I am doing following to run a remote-machine's process on that remote-machine: ConnectionOptions objConnectionOptions = new ConnectionOptions(); objConnectionOptions.Impersonation = ImpersonationLevel.Impersonate; objConnectionOptions.EnablePrivileges = true; objConnectionOptions.Username = strUserName; objConnectionOptions.Password = strPassword; ManagementScope objManagementScope = new ManagementScope(@"\\remote-machine-name\ROOT\CIMV2", objConnectionOptions); objManagementScope.Connect(); ManagementClass processClassFinal = new ManagementClass(objManagementScope, new ManagementPath("Win32_Process"), null); ManagementBaseObject inParamsFinal = processClassFinal.GetMethodParameters("Create"); inParamsFinal["CommandLine"] = @"\\remote-machine-name\some-directory\someProgram.exe"; ManagementBaseObject outParamsFinal = processClassFinal.InvokeMethod("Create", inParamsFinal, null); But for some reason it does not work and I don't know why??????? outParamsFinal["processId"] returns null, instead of a valid processId. Is there any one who could help me in that.............. Thanks Sarfraz
Perhaps a review of the Win32_Process.Create[^] are in order: The Create WMI class method creates a new process. A fully-qualified path must be specified in cases where the program to be launched is not in the search path of Winmgmt.exe. If the newly created process attempts to interact with objects on the target system without the appropriate access privileges, it is terminated without notification to this method. For security reasons the Win32_Process.Create method cannot be used to start an interactive process remotely.
Dave Kreskowiak Microsoft MVP - Visual Basic
-
Perhaps a review of the Win32_Process.Create[^] are in order: The Create WMI class method creates a new process. A fully-qualified path must be specified in cases where the program to be launched is not in the search path of Winmgmt.exe. If the newly created process attempts to interact with objects on the target system without the appropriate access privileges, it is terminated without notification to this method. For security reasons the Win32_Process.Create method cannot be used to start an interactive process remotely.
Dave Kreskowiak Microsoft MVP - Visual Basic
-