Is there any DOS command to reboot computer ?
登录 | 论坛导航 -> 华新鲜事 -> 技术の宅 | 本帖共有 6 楼,分 1 页, 当前显示第 1 页 : 本帖树形列表 : 刷新 : 返回上一页
<<始页  [1]  末页>>
作者:flu (等级:4 - 马马虎虎,发帖:478) 发表:2004-06-16 10:26:16  楼主  关注此帖
Is there any DOS command to reboot computer ?
hh
欢迎来到华新中文网,踊跃发帖是支持我们的最好方法!原文 / 传统版 / WAP版所有回复从这里展开收起列表
作者:flu (等级:4 - 马马虎虎,发帖:478) 发表:2004-06-16 10:53:28  2楼
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!

欢迎来到华新中文网,踊跃发帖是支持我们的最好方法!原文 / 传统版 / WAP版所有回复从这里展开收起列表
作者:flu (等级:4 - 马马虎虎,发帖:478) 发表:2004-06-16 11:01:06  3楼
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.
thank you! i see, i just want to find an easier method
欢迎来到华新中文网,踊跃发帖是支持我们的最好方法!原文 / 传统版 / WAP版所有回复从这里展开收起列表
作者:flu (等级:4 - 马马虎虎,发帖:478) 发表:2004-06-16 11:15:35  4楼
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? :(
欢迎来到华新中文网,踊跃发帖是支持我们的最好方法!原文 / 传统版 / WAP版所有回复从这里展开收起列表
作者:flu (等级:4 - 马马虎虎,发帖:478) 发表:2004-06-16 14:18:11  5楼
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.
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~
欢迎来到华新中文网,踊跃发帖是支持我们的最好方法!原文 / 传统版 / WAP版所有回复从这里展开收起列表
作者:flu (等级:4 - 马马虎虎,发帖:478) 发表:2004-06-16 16:00:12  6楼
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.
-_-!
欢迎来到华新中文网,踊跃发帖是支持我们的最好方法!原文 / 传统版 / WAP版所有回复从这里展开收起列表
论坛导航 -> 华新鲜事 -> 技术の宅 | 返回上一页 | 本主题共有 6 篇文章,分 1 页, 当前显示第 1 页 | 回到顶部
<<始页  [1]  末页>>

请登录后回复:帐号   密码