Search code examples
c#processcmdshutdown

how to shutdown-restart-hibernate-stand by-log off computer using Process.Start()?


Im making a client-server application so i need to shutdown the remote pc Silently .. i've read about shutdown arguments in Commands Prompt shutdown/? .. but i still don't know the right arguments to do the commands below.

  • shutdown
  • restart
  • hibernate
  • stand by
  • log off
  • lock (switch user)

    so how do i do those commands locally without (/m) ?

    void ShutDown(string cmd)
    {
        Process.Start("shutdown", cmd);
    }
    

    thanks in advance.


  • Solution

  • Try this:

    To ShutDown : shutdown -s

    To Restart : shutdown -r

    To Logoff : shutdown -l

    To Hibernate :%windir%\system32\rundll32.exe PowrProf.dll,SetSuspendState

    To Lock : Rundll32.exe User32.dll,LockWorkStation

    To Sleep : rundll32.exe powrprof.dll,SetSuspendState 0,1,0

    Note:While using cmd for Sleep Need to off Hibernation else sys will be hibernated.