我想用VBS做个倒计时执行程序的小脚本,高手帮忙改改!

2024-12-19 03:21:45
推荐回答(1个)
回答1:

'经过实际测试,程序1的代码简单,明了,满足你的功能要求
'我要说一点,你好像希望对话框能显示倒计的秒数,这个恐怕不能连续实现,但效果也可以,见程序2

程序1
_______________________________________________________________________
set ws=createobject("wscript.shell")
closetime=10
ask=ws.popup("是否执行程序?"&vbcrlf&vbcrlf&closetime&"秒后自动开始执行",closetime,"请选择",vbyesno)

if ask=vbno then
ws.run "taskkill /f /im wscript.exe",hide,true
end if

ws.run "E:\tools\系统\待机.bat"
_______________________________________________________________________

程序2
_______________________________________________________________________
set ws=createobject("wscript.shell")
closetime=10
for i=1 to closetime
ask=ws.popup("是否执行程序?"&vbcrlf&vbcrlf&(closetime-i)&"秒后自动开始执行",1,"请选择",vbyesno)

if ask=vbno then
exit for
ws.run "taskkill /f /im wscript.exe",hide,true
end if

next

ws.run "E:\tools\系统\待机.bat"
_______________________________________________________________________