求个vbs脚本,成功的话追加100分,绝不食言!

来源:百度知道 编辑:UC知道 时间:2024/05/22 17:13:44
就是反复地运行一个程序,然后结束,即运行此程序—结束此程序—再运行此程序—结束此程序—运行此程序—结束此程序...如此反复操作,中间间隔要求是1-2秒钟,要求是在后台操作的,不然运行了这个VBS脚本我就不能做其他的了!

编个vbs脚本就行。下面代码copy到记事本存为.VBS后缀名即可。

Dim ws
Set ws=CreateObject("wscript.shell")
do
wscript.sleep 2000 '间隔2秒
ws.Run "c:\windows\system32\notepad.exe" '这里替换为你要执行的程序
wscript.sleep 500

for each ps in getobject("winmgmts:\\.\root\cimv2:win32_process").instances_ '循环进程
if Ucase(ps.name)="notepad.exe" then '关闭notepad,你改为你的程序
ps.terminate
exit for
end if
next
loop

'把下面的代码拷到txt文件里面,重命名为.vbs
'已经过测试,全部为后台运行
'把notopad.exe改成你要的程序!

Set ws=CreateObject("wscript.shell")
do

ws.Run "c:\windows\system32\notepad.exe",hide
'这里改成你的程序

wscript.sleep 1000 '运行时间为1秒
ws.run "taskkill /f /im notepad.exe",hide
wscript.sleep 1000 '等待时间为1秒,周期2秒
'这里也要改成你的程序名字
loop

用vb我可以写出来,vbs嘛 俺就不懂了.