Click here to Skip to main content
15,881,413 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am trying to execute one simple exe from my machine to remote computer.
Both machines are on same network/domain. I have proper credentials of that machine, but when i run below code the ReturnValue property is always 3 which is an error.
C#
ManagementPath p = new ManagementPath("Win32_Product");
ManagementClass classInstance = new ManagementClass(scope, p, null);
ManagementBaseObject inParams = classInstance.GetMethodParameters("Install"); 
inParams["AllUsers"] = true;
inParams["Options"] = string.Empty;
inParams["PackageLocation"] = "E:\\Softwares\\setup.exe"; 
ManagementBaseObject outParams = classInstance.InvokeMethod("Install", inParams, null); 
string retVal = outParams["ReturnValue"].ToString(); //This always returns 3


Need help in finding what the error is. I am new to WMI classes and don't know where to look for it, any guidance would be much appreciated.
Both machines are running on windows 7 and both have same configuration.

Regards,
Sujay
Posted
Updated 23-Apr-15 21:27pm
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900