actually i am doing vb6.0 proj. any suggestion to reboot?SYNTAX
Usage: shutdown [-i | -l | -s | -r | -a] [-f] [-m \\computername] [-t xx] [-c "comment"] [-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 warning
-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 less than 256)
yy is the minor reason code (positive integer less than 65536)
the shutdown -r command has a problem, 30s delay....
i want a immediate restart,just like the restart window after a software installation.both DOS cmd & vb methods are OK.any?
you can use "-t 0" as indicated in my post above.
BTW, this "shutdown" command is available only on WinXP (or Win2k/NT with Resource Kit). So as you are on a VB project, you might actually consider calling the Win32 API instead, which is examplified in the shutdown commands for Win2k/NT as indicated in that post.
my code:Const EWX_LOGOFF = 0
Const EWX_SHUTDOWN = 1
Const EWX_REBOOT = 2
Const EWX_FORCE = 4
Private Declare Function ExitWindowsEx Lib "user32" (ByVal uFlags As Long, ByVal dwReserved As Long) As Long
Private Sub Form_Load()
msg = MsgBox("This program is going to reboot your computer. Press OK to continue or Cancel to stop.", vbCritical + vbOKCancel + 256, App.Title)
If msg = vbCancel Then End
'reboot the computer
ret& = ExitWindowsEx(EWX_FORCE Or EWX_REBOOT, 0)
Unload Me
End Sub
what is SE_SHUTDOWN_NAME privilege? blur~
Note that there are a lot other stuff in the sample code. But what you should pay attention to is the part there the current process's privilege tokens are checked, and adjusted, in order to enable the process to shutdown the OS.
cool...butWhat is the point of returning a variable if your windows is shutting down? ;)
ret& = ExitWindowsEx(EWX_FORCE Or EWX_REBOOT, 0)
The shutdown request may fail.
BTW, as a user-mode process, shutting down is NEVER the last thing the process will do. In most cases, final clean-up should be performed after that, and before your process actually exits.