在许多论坛上找到了这个Reboot Vista.vbs脚本。似乎整个帖子(包括代码的文本)都发布在很多论坛上。所以我不知道原作者是谁。下面是代码:
Option Explicit
On Error Resume Next
Dim Wsh, Time1, Time2, Result, PathFile, MsgResult, MsgA, AppName, KeyA, KeyB, TimeDiff
MsgA = "Warning! Close all running programs and click on OK."
KeyA = "HKEY_CURRENT_USER\Software\RestartTime\"
KeyB = "HKEY_CURRENT_USER\Software\Microsoft\Windows\Curr e ntVersion\Run\RestartTime"
AppName = "Boot Up Time"
Set Wsh = CreateObject("WScript.Shell")
PathFile = """" & WScript.ScriptFullName & """"
Result = wsh.RegRead(KeyA & "Times")
if Result = "" then
MsgResult = Msgbox (MsgA, vbOKCancel, AppName)
If MsgResult = vbcancel then WScript.Quit
Wsh.RegWrite KeyA & "Times", left(Time,8), "REG_SZ"
Wsh.RegWrite KeyB, PathFile, "REG_SZ"
Wsh.Run "cmd /c Shutdown -r -t 00", false, 0
else
Wsh.RegDelete KeyA & "Times"
Wsh.RegDelete KeyA
Wsh.RegDelete KeyB
TimeDiff = DateDiff("s",Result,left(Time,8))
MsgBox "Your system reboots in " & TimeDiff & " seconds", VbInformation, AppName
end if
wscript.Quit
应该重启Vista,重新启动后,显示重启所花费的时间。 它重新启动正常和一切,但对话框不会弹出。我必须再次手动点击脚本才能出现?我认为这会破坏脚本的目的吗?
任何帮助都会非常感谢fellas。
答案 0 :(得分:1)
regpath中不能有空格:将“Curr e ntVersion”更改为“CurrentVersion”
这一行:
Wsh.RegWrite KeyB, PathFile, "REG_SZ"
如果PathFile和KeyB正确,将注册脚本以自动启动Windows,但在“Curr e ntVersion”中有空格它将无效。
答案 1 :(得分:0)
也许您收到的错误会阻止显示消息框?您在脚本开头的这一行将导致它忽略所有错误:
On Error Resume Next
你应该删除这一行,然后再次运行它,看看发生了什么。