Windows 7关闭隐藏的消息框

时间:2014-11-12 09:33:49

标签: windows batch-file vbscript system-shutdown

Windows 7
简单的.bat和.vbs文件
级别:血腥的初学者
摘要:在" shutdown.exe" -call

期间禁止窗口关闭消息框

我试图运行一个简单的系统关闭,同时清除我的临时文件并提供中止选项。到目前为止,我几乎达到了我的目标,使用一些简单的文件在另一个之后调用。

清除临时数据

rmdir /s /q "C:\Users\myusername\AppData\Local\Temp"

执行关机

c:\windows\system32\shutdown -s -f -t 30

然后我创建了一个消息框,允许我按OK按钮中止关机:

x=msgbox ("Temp files cleared. Executing system shutdown now!" & vbNewLine & "Press OK to abort shutdown.",262144+48+0, "System Shutdown")

If x=vbOk Then
Dim objShell
Set objShell = WScript.CreateObject("WScript.Shell")
objShell.Run "abortShutdown.bat"
end if

(abortShutdown.bat只是shutdown /a

系统正常关闭,中止也正常。问题是,Windows 7正在向我显示一个额外的消息框,表示类似于" Windows将在不到1分钟内关闭"。

因此,我的屏幕上有2个消息框,但我只想查看.vbs文件中的自定义框。至少我设法将我的自定义框移到了前面......我也尝试了所谓的无声WshShell.RunSet WshShell = Nothing解决方法但没有成功。消息框仍然会弹出。

如何完全压制此框?

1 个答案:

答案 0 :(得分:1)

我会使用稍微不同的方法:

timeout = 30 'seconds

Set sh = CreateObject("WScript.Shell")

x = sh.Popup("Temp files cleared. Shutting down in " & timeout & " seconds!" & _
      vbNewLine & "Press OK to shutdown immediately." & vbNewLine & _
      "Press Cancel to abort shutdown.", timeout, "System Shutdown", vbOKCancel)

If x = vbCancel Then
  sh.Run "shutdown -a"
Else
  sh.Run "shutdown -s -f -t 0"
End If