Reputation: 1988
I have this code:
ConnectionOptions connOptions = new ConnectionOptions();
connOptions.Impersonation = ImpersonationLevel.Impersonate;
connOptions.EnablePrivileges = true;
ManagementScope manScope = new ManagementScope(String.Format(@"\\{0}\ROOT\CIMV2", sHost), connOptions);
manScope.Connect();
ObjectGetOptions objectGetOptions = new ObjectGetOptions();
ManagementPath managementPath = new ManagementPath("Win32_Process");
ManagementClass processClass = new ManagementClass(manScope, managementPath, objectGetOptions);
ManagementBaseObject inParams = processClass.GetMethodParameters("Create");
inParams["CommandLine"] = "notepad.exe";
ManagementBaseObject outParams = processClass.InvokeMethod("Create", inParams, null);
When I set sHost to be my local IP address, it works and notepad opens. However, when I set it to be the remote server, nothing happens.
(I'm able to connect to the remote computer and copy files from my application - this is just for trying to run stuff remotely. Firewall has also been configure for WMI).
Kinda have no more ideas...
Thanks.
Upvotes: 0
Views: 1455
Reputation: 2289
Maybe, you should use PsTools (run from your app) ? Ideally for remote deploying.
Upvotes: 2