I was trying to call a .cmd file remotely thru WMI in C# with code below:
ObjectGetOptions objectGetOptions = new ObjectGetOptions();
ManagementPath managementPath = new ManagementPath("Win32_Process");
ManagementClass processClass = new ManagementClass
(manScope, managementPath, objectGetOptions);
ManagementBaseObject inParams = processClass.GetMethodParameters("Create");
inParams["CommandLine"] = @"C:\temp\text.cmd";
Above code returned no error, it even got process ID with outParams["processId"] However, it didn't do anything at remote server. I then tried calling a vbs script with same procedure and it worked just fine. So my question is, what is the proper way to call a .cmd file through WMI? For vbs, I knew I should include the CScript command. But how about .CMD file?
Thanks in advance.