[VBS] 使用vbs文件保证程序运行,并模拟键盘回车键

代码如下,注意修改红色部分

do 
Dim Shell
Set Shell=WScript.CreateObject("WScript.Shell")
dim OK,oShell 
OK=False 
set bag=getobject("winmgmts:\\.\root\cimv2") 
set pipe=bag.execquery("select * from win32_process where name='Portal.exe'") 
For Each id In pipe 
OK = True 
Next 
If not OK Then 
Shell.Run "e:\Portal.exe"
WScript.Sleep 10000 
Shell.SendKeys "{ENTER}"
end if 
WScript.sleep 60000 
loop

posted @ 2010-04-21 11:12  DavidHHuan  阅读(1109)  评论(0编辑  收藏  举报