Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# .NET Process WMI command
Hi Guys,
 
I was just creating a small tool to execute shell commands on remote machine and get output and errors.
 
I am running my application under all privileges.
 
Example : I should be able to run dir /a on remote machine and get output and so on for other commands.
 
I just browsed for it and found that psexec is a tool provided to do this task. But I want to do this using .net framework.
 
If I will used WMI then I can't know when then process is finished and read output.
 
Anyone have done that before.
 
Thanks
Posted 29-Jul-12 22:51pm

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

  Permalink  
Comments
sunder.tinwar at 30-Jul-12 4:30am
   
thanks for reply. now read this : http://stackoverflow.com/questions/1405209/how-to-execute-a-command-in-a-remote-machine-and-get-the-output-using-c-net
 
here with WMI approach we can't identify when the process is finished execution.
Zoltán Zörgő at 30-Jul-12 4:43am
   
Might happen. But you have other wmi tools to follow it's execution: http://stackoverflow.com/questions/8915244/create-remote-process-via-wmi-and-wait-for-it-to-exit
sunder.tinwar at 30-Jul-12 4:47am
   
thats gone make my code very critical. I need to handle event for each command if i end up using multithreading.
I am looking for simple C# solution if possible. If not then I will think over WMI.
Zoltán Zörgő at 30-Jul-12 5:05am
   
As I know PSExec is starting a service remotely, and passing the command/application to it. I have not found any Win32API call that might be used to create a process remotely.
sunder.tinwar at 30-Jul-12 5:40am
   
yes i wanted to create something like psexec only. is there any other work around also?
Zoltán Zörgő at 30-Jul-12 5:47am
   
Might worth looking around here: http://talhatariq.wordpress.com/2006/04/14/the-open-source-psexec/
sunder.tinwar at 31-Jul-12 4:52am
   
anyone knows simple .net approach to solve this.

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



Advertise | Privacy | Mobile
Web03 | 2.8.150301.1 | Last Updated 30 Jul 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100