Is there any DOS command to reboot computer ?[flu (6-16 10:26, Long long ago)] [ 传统版 | sForum ][登录后回复]1楼
Type help in cmd windowsee the commands and explanantions[MrDJay (6-16 10:38, Long long ago)] [ 传统版 | sForum ][登录后回复]2楼
(引用 MrDJay:Type help in cmd windowsee the commands and explanantions)HELP command is not as powerful as man in the *nix world.HELP provides only built-in command's list. But a lot of things in Windows have to be achieved via Win32 API instead.[Flying (6-16 10:48, Long long ago)] [ 传统版 | sForum ][登录后回复]3楼
(引用 MrDJay:Type help in cmd windowsee the commands and explanantions)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?
thanks!
[flu (6-16 10:53, Long long ago)]
[ 传统版 |
sForum ][登录后回复]4楼
What's your OS?[Got from alt.dos.batch newsgroup:]
DOS/Win3x:
ECHO G=FFFF:0000 | debug
Win9x
rundll user.exe,ExitWindowsExec
Win98/Me
rundll32 shell32.dll,SHExitWindowsEx 2
WinNT/2k (with Resource Kit)
shutdown /L /R /T:0 /Y
WinNT/2k (without Resource Kit)
@ECHO OFF & cd/d %temp% & echo [version] > {out}.inf
(set inf=InstallHinfSection DefaultInstall)
echo signature=$chicago$ >> {out}.inf
echo [defaultinstall] >> {out}.inf
rundll32 setupapi,%inf% 1 %temp%\{out}.inf
del {out}.inf
WinXP
shutdown -r -t 0
[Flying (6-16 10:56, Long long ago)]
[ 传统版 |
sForum ][登录后回复]5楼
(引用 flu:actually i am doing vb6.0 proj. any suggestion to reboot?SYNTAX Usage: shutdown [-i | -l | -s | -r | -a] [-f] [-m \\computernam...)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.[Flying (6-16 10:58, Long long ago)] [ 传统版 | sForum ][登录后回复]6楼
(引用 Flying:you can use "-t 0" as indicated in my post above.BTW, this "shutdown" command is available only on WinXP (or Win2k/NT with Resou...)thank you! i see, i just want to find an easier method[flu (6-16 11:01, Long long ago)] [ 传统版 | sForum ][登录后回复]7楼
(引用 flu:thank you! i see, i just want to find an easier method)For VB programming, using the API is actually easier.You don't have to take care of path, user's OS, etc.[Flying (6-16 11:05, Long long ago)] [ 传统版 | sForum ][登录后回复]8楼
(引用 Flying:For VB programming, using the API is actually easier.You don't have to take care of path, user's OS, etc.)i use ExitWindowsEx , doesnot work? :([flu (6-16 11:15, Long long ago)] [ 传统版 | sForum ][登录后回复]9楼
(引用 flu:i use ExitWindowsEx , doesnot work? :()how does your code look like?API Function
Declare Function ExitWindowsEx Lib "user32" Alias "ExitWindowsEx" (ByVal uFlags As Long, ByVal dwReserved As Long) As Long
use EWX_REBOOT for uFlags.
BTW, the calling process must have SE_SHUTDOWN_NAME privilege in order for this to work.
[Flying (6-16 11:56, Long long ago)]
[ 传统版 |
sForum ][登录后回复]10楼
(引用 Flying:how does your code look like?API Function
Declare Function ExitWindowsEx Lib "user32" Alias "ExitWindowsEx" (ByVal uFlags As Lon...)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~[flu (6-16 14:18, Long long ago)]
[ 传统版 |
sForum ][登录后回复]11楼
(引用 flu:my code:Const EWX_LOGOFF = 0
Const EWX_SHUTDOWN = 1
Const EWX_REBOOT = 2
Const EWX_FORCE = 4
Private Declare Function ExitWindow...)Check out the sample code there:http://www.vbaccelerator.com/home/VB/Tips/How_to_Shutdown_the_System_in_Windows_9x_and_NT/article.asp
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.[Flying (6-16 15:35, Long long ago)]
[ 传统版 |
sForum ][登录后回复]12楼
(引用 Flying:Check out the sample code there:http://www.vbaccelerator.com/home/VB/Tips/How_to_Shutdown_the_System_in_Windows_9x_and_NT/articl...)-_-![flu (6-16 16:00, Long long ago)] [ 传统版 | sForum ][登录后回复]13楼
(引用 flu:my code:Const EWX_LOGOFF = 0
Const EWX_SHUTDOWN = 1
Const EWX_REBOOT = 2
Const EWX_FORCE = 4
Private Declare Function ExitWindow...)cool...butWhat is the point of returning a variable if your windows is shutting down? ;)
ret& = ExitWindowsEx(EWX_FORCE Or EWX_REBOOT, 0)
[kelvin (6-16 17:17, Long long ago)]
[ 传统版 |
sForum ][登录后回复]14楼
(引用 kelvin:cool...butWhat is the point of returning a variable if your windows is shutting down? ;) ret& = ExitWindowsEx(EWX_FORCE Or EWX_)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.[Flying (6-16 17:38, Long long ago)] [ 传统版 | sForum ][登录后回复]15楼