Shutdown Workstation

  • Thread starter Thread starter ClearShort_Answer
  • Start date Start date
C

ClearShort_Answer

Hi there,

I would like to know how to write a simple program to shut down my
workstation. I searched the MSDN but I could not find any hint for my
problem. Perhaps I searched for the wrong keywords?!?
It would be very kind if someone would help me.

Best Jean
 
ClearShort_Answer said:
Hi there,

I would like to know how to write a simple program to shut down my
workstation. I searched the MSDN but I could not find any hint for my
problem. Perhaps I searched for the wrong keywords?!?
It would be very kind if someone would help me.

Best Jean

From the command line:

%windir%\System32\shutdown.exe -s -t 0

Using C#:

[DllImport ("user32")]
public static extern int ExitWindowsEx(int dwReserved, int uReturnCode);

const int EWX_LOGOFF = 0;
const int EWX_SHUTDOWN = 1;
const int EWX_REBOOT = 2;
const int EWX_FORCE = 4;

ExitWindowsEx(0, EWX_SHUTDOWN|EWX_FORCE);
 
Back
Top