Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Force reboot

Status
Not open for further replies.

jubble

Programmer
Mar 6, 2002
207
GB
Due to the painful experience of trying to get an combined prerequisites + application + MSDE + script deployment working seamlessly (it works on NT,2000,XP but Win98 and ME force an uncontrollable reboot which screws everything up) I'm experimenting with a workaround.
For this to work I need to force a reboot from my VB.Net app...is this possible?
 
There are several ways you could do it. The easiest is probably just to shell out (or start a new process which is the better method) to shutdown.exe (which is located at C:\WINDOWS\system32\shutdown.exe if you are using Windows XP). You can just pass it parameters to force a reboot:
Code:
Usage: shutdown [-i | -l | -s | -r | -a] [-f] [-m \\computername] [-t xx] [-c "c
omment"] [-d up:xx:yy]

        No args                 Display this message (same as -?)
        -i                      Display GUI interface, must be the first option
        -l                      Log off (cannot be used with -m option)
        -s                      Shutdown the computer
        -r                      Shutdown and restart the computer
        -a                      Abort a system shutdown
        -m \\computername       Remote computer to shutdown/restart/abort
        -t xx                   Set timeout for shutdown to xx seconds
        -c "comment"            Shutdown comment (maximum of 127 characters)
        -f                      Forces running applications to close without war
ning
        -d [u][p]:xx:yy         The reason code for the shutdown
                                u is the user code
                                p is a planned shutdown code
                                xx is the major reason code (positive integer le
ss than 256)
                                yy is the minor reason code (positive integer le
ss than 65536)
So something like the following should work:
Code:
shutdown.exe -r -t 0

--------------------------------------------------------------------------------------------------------------------------------------------

Need help finding an answer?

Try the search facility ( or read FAQ222-2244 on how to get better results.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top