|
-
Aug 24th, 2006, 01:12 PM
#1
Thread Starter
PowerPoster
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?
-
Aug 24th, 2006, 06:00 PM
#2
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.
-
Aug 24th, 2006, 06:03 PM
#3
Thread Starter
PowerPoster
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,
-
Aug 24th, 2006, 06:33 PM
#4
Thread Starter
PowerPoster
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
-
Aug 24th, 2006, 07:11 PM
#5
Thread Starter
PowerPoster
Re: CreateProcess WMI C#
got it!
ManagementClass should be constructed with this string:
"\\\\server\\root\\cimv2:Win32_Process"
-
Aug 24th, 2006, 07:21 PM
#6
Re: CreateProcess WMI C#
and oh instead of using \ for escape character use @.
i.e @\\server\root\cimv2
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|