I have the code using WMI to run my executable app from remote machine via net use command, it didn't work all the time. I tried monitoring the process in the remote machine with Process Monitor, and found this:
It showed that my app can't be accessed from remote machine. I changed this folder to total control privilege for everyone, but it still didn't work.
Following is the relevant code:
ObjectGetOptions options = new ObjectGetOptions();
ManagementPath path = new ManagementPath("Win32_Process");
ManagementClass proc = new ManagementClass(scope, path, options);
ManagementBaseObject inParams = proc.GetMethodParameters("Create");
...
inParams["CommandLine"] = "cmd /c " + sMap + " & " + sCopy + " & " + sDel;
ManagementBaseObject outParams = proc.InvokeMethod("Create", inParams, null);
The combined cmd
command for remote machine is as follows:
cmd /c net use \\\\REMOTEMACHINE\\REFOLDER /user:REMOTEMACHINE\\administrator Abc@1 & \\REMOTEMACHINE\LDLOGON\CltPst.exe "/S=http://REMOTEMACHINE/xxx/mycig.exe?prefix=vulscan\\&name=b3dd7fd6-ccee-4418-a43f-17a8df04875a.dsc" "/F=c:\\users\\administrator\\appdata\\roaming\\xxx\\yyy\\zzz.txt" & net use \\REMOTEMACHINE\REFOLDER /del
I total have no idea what's going on here, I will be appreciated if anyone can help with this.