Starting a process in c# to perform a remote shutdown using command line parameters

219 views
Skip to first unread message

board.ch...@googlemail.com

unread,
May 21, 2009, 5:41:11 PM5/21/09
to DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML Web Services,.NET Remoting
Hi all,

I am developing a c# application that will enable users to perform a
remote shutdown on computers. I have got the code working to a degree.
I am able to run shutdown -r -t 50. and my computer shutsdown fine. If
i try
shutdown -m \\computer_name -r -t 50 the command prompt window opens
and closes but nothin happens. computer_name is the name of my local
computer. I can enter the command directly into the command prompt and
my computer shutsdown fine without any problems.

Below is the code that I have

Process p = new Process();
p.StartInfo.FileName = "shutdown";
p.StartInfo.UseShellExecute = false;
p.StartInfo.CreateNoWindow = false;
p.StartInfo.Arguments = "-r -t 50 -m \\dell_pc";
//p.StartInfo.Arguments = "-A";
p.StartInfo.RedirectStandardOutput = true;
p.Start();
Console.WriteLine(p.StandardOutput.ReadToEnd());

This code is within a try/catch. And no errrors are thrown

Any help in this matter would be highly appreciated.

Thank you

Benj Nunez

unread,
Jun 9, 2009, 9:34:16 PM6/9/09
to DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML Web Services,.NET Remoting
Why re-invent the wheel? So to speak. :)

http://dimio.altervista.org/eng/


Benj





On May 22, 5:41 am, "board.christop...@googlemail.com"
Reply all
Reply to author
Forward
0 new messages