|
-
Sep 17th, 2009, 05:04 AM
#1
Thread Starter
New Member
[RESOLVED] Starting program on remote pc
Hello.
Please help me with this code.
I don't understand how I can get this to work!!!
Code:
Dim co As ConnectionOptions = New ConnectionOptions()
co.Username = "username"
co.Password = "password"
Dim mp As ManagementPath = New ManagementPath("\\targetMachine\root\cimv2:Win32_process")
Dim mc As ManagementClass = New ManagementClass(mp, co)
mc.InvokeMethod("Create", New Object() {"calc.exe"})
-
Sep 17th, 2009, 06:59 AM
#2
Re: Starting program on remote pc
What don't you understand? It seems like a pretty simple example to me.
-
Sep 17th, 2009, 07:33 AM
#3
Thread Starter
New Member
Re: Starting program on remote pc
Well... It doesn't work!!!
ManagementClass overload don't support ConnectionOptions...
So... How am I supposed to do this???
-
Sep 17th, 2009, 08:24 AM
#4
Re: Starting program on remote pc
The error message is telling you the problem. No constructor for the ManagementClass takes a connectionOptions object. Where did you get this code from?
-
Sep 18th, 2009, 03:31 AM
#5
Thread Starter
New Member
Re: Starting program on remote pc
A friend of my wrote a similar code in C#, and I tried to convert it to VB.
This is what I got from it...
But if you see what i'm trying to do with the code here, could you maybe point me in the right direction?!
-
Sep 18th, 2009, 06:52 AM
#6
Re: Starting program on remote pc
Do you have the C# code that works?
-
Sep 18th, 2009, 08:12 AM
#7
Thread Starter
New Member
Re: Starting program on remote pc
I'm not sure if it even works, but this is what my friend gave me:
Code:
ConnectionOptions co = new ConnectionOptions("username and password here");
ManagementPath mp = new ManagementPath(@"\\targetMachine\root\cimv2:Win32_process");
ManagementClass mc = new ManagementClass(mp, co);
I tried to search google and msdn but I can't find anything about this...
This is what I want:
I have a server called myserver and a computer called mypc (example!).
On myserver (local), I have created a batch file in system root that deletes some log files.
Normaly I would log on to myserver (RDP) to execute this batchfile...
I'm trying to create a program I can run locally on mypc which executes the batchfile locally on myserver...
I Hope you understand what I'm trying to do here... My English isn't very good.
-
Sep 18th, 2009, 08:27 AM
#8
Re: Starting program on remote pc
I think you want something more like this (Code which I generated from the WMICodeCreator):
Code:
Dim connection As New ConnectionOptions
connection.Username = userNameBox.Text
connection.Password = passwordBox.Text
connection.Authority = "ntlmdomain:DOMAIN"
Dim scope As New ManagementScope( _
"\\FullComputerName\root\CIMV2", connection)
scope.Connect()
Dim classInstance As New ManagementClass( _
scope, _
New ManagementPath("Win32_Process"), Nothing)
-
Sep 18th, 2009, 09:47 AM
#9
Thread Starter
New Member
Re: Starting program on remote pc
Yes, I think we're on to something here!
I just don't understand where to put the path to my batchfile...
-
Sep 18th, 2009, 09:53 AM
#10
Re: Starting program on remote pc
-
Sep 18th, 2009, 09:57 AM
#11
Thread Starter
New Member
Re: Starting program on remote pc
No.... I think it's because I type the code wrong or something!
Code:
("Win32_Process.create("calc.exe")")
Could you maybe give me an example whit calc.exe ot notepad.exe?!
-
Sep 21st, 2009, 04:36 AM
#12
Thread Starter
New Member
Re: Starting program on remote pc
-
Sep 21st, 2009, 08:28 AM
#13
Re: Starting program on remote pc
Download the WMI Code creator that I linked in post 8. You should be able to use that to get the code that works.
-
Sep 21st, 2009, 09:44 AM
#14
Thread Starter
New Member
Re: Starting program on remote pc
I found this link, and it works 
http://weblogs.asp.net/steveschofiel...als_2E00_.aspx
The code is also very similar to the one provided by the WMI Code Creator.
Thanks for all the help, and I really hope this thread will help other people with the same problem.
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
|