Restarting a computer in C#

  • Thread starter Thread starter sheperson
  • Start date Start date
S

sheperson

Hi,
Does anyone know how to restart a computer using C# code? I can use
shutdown -r command but this is not a good choice because it takes 30
seconds to restart.
I have made a wizard for one of my applications which configures the
application; and at the end of the wizard I want to restart the
computer to make some changes take effect.
Thanks in advance.
 
Hi,
Does anyone know how to restart a computer using C# code? I can use
shutdown -r command but this is not a good choice because it takes 30
seconds to restart.
I have made a wizard for one of my applications which configures the
application; and at the end of the wizard I want to restart the
computer to make some changes take effect.

You can either

1. Do it 'properly' by P/Invoking ExitWindowsEx in user32.dll
2. Use shutdown -t 0 -r

Alun Harford
 
Back
Top