-
CreateProcess WMI C#
back again with another question.
I want to remotely create and run a process on that remote computer using WMI. I am having problems but getting closer I believe
Error when trying to invoke method:
"Operation is not valid due to the current state of the object"
Code:
ManagementPath thePath = new ManagementPath("\\\\server\\root\\cimv2");
ManagementClass theClass = new ManagementClass(thePath);
theClass.InvokeMethod("Create", new object[] { "Calc.exe" });
any ideas?
-
Re: CreateProcess WMI C#
I would suggest that you use the MgmtClassGen.exe utility to generate a .NET class that corresponds to the WMI class you want to use. That way you will be using objects of the appropriate type and calling methods directly instead of using things like InvokeMethod. That way you'll get Intellisense too.
-
Re: CreateProcess WMI C#
Thank you. I do appreciate this however for now is it possible to find out what the error actually means and get to the root of the problem?
ill look into the suggested tool however it would be nice to find out how to resolve the error as it stands, apart from using this tool, :)
-
Re: CreateProcess WMI C#
PS - the above code does work fine locally but not on the remote computer. locally running WS2003 SP1 and on the other one Windows 2000 PRO SP4
-
Re: CreateProcess WMI C#
got it!
ManagementClass should be constructed with this string:
"\\\\server\\root\\cimv2:Win32_Process"
-
Re: CreateProcess WMI C#
and oh instead of using \ for escape character use @.
i.e @\\server\root\cimv2