7

I use the following code for shutdown the own System.It was working Fine.And I need to shut down another System, which is connected in LAN Connection. I'm unable to do it with this code. How to Shutdown another System using shutdown.exe? My OS is windows7.

using System.Diagnostics;


        protected void Button1_Click(object sender, EventArgs e)
        {
            Process.Start("shutdown.exe", "-s -t 00");

        }
CRoshanLG
  • 498
  • 1
  • 8
  • 20
V.V
  • 875
  • 3
  • 25
  • 54
  • also hope you make sure you have admin rights in the other system. next time you want to check for options for a command try the help for the command in command prompt. – Naveen Babu Nov 23 '12 at 05:53
  • @SimonWhitehead I use like this Process.Start("shutdown.exe", "-s -t 00 //ComputerName");.It will not work for me.. – V.V Nov 23 '12 at 05:55
  • 1
    Try `\\Computername`, not `//Computername`. – Andrew Sklyarevsky Nov 23 '12 at 06:05
  • Check these answers these might help you. http://stackoverflow.com/questions/11104765/c-sharp-using-shutdown-exe-just-shutdown http://stackoverflow.com/questions/6966924/how-to-shutdown-machine-from-asp-net – Krishna Thota Nov 23 '12 at 06:08
  • @AndrewSklyarevsky I use both //Computername and \\Computername.Both are not working.. – V.V Nov 23 '12 at 06:08
  • `shutdown /m \\computername`? – J0HN Nov 23 '12 at 06:42
  • Tried running the same command from console, outside of C#? Maybe it just don't work? – J0HN Nov 23 '12 at 06:50
  • 1
    This is the exact command I used today to do this: `shutdown -m \\au2068serv.local -r` to restart a server located on my desk (with no screen attached). That should work (I'm on Win7). – Simon Whitehead Nov 23 '12 at 07:24
  • @SimonWhitehead I do like this way, protected void Button1_Click(object sender, EventArgs e) { Process.Start("shutdown -m \\servername.systemName -r"); }.It causes the error – V.V Nov 23 '12 at 09:05

2 Answers2

1

Menu Start->Run->type cmd-> press enter

in cmd type

shutdown /?

You can see help, according to help the key you need is

   /m \\computer Specify the target computer.
Alex Veremeenko
  • 338
  • 2
  • 4
1

Just for completeness:

Process.Start("shutdown.exe", "-s -t 00 \\computer");
looper
  • 1,929
  • 23
  • 42