【发布时间】:2015-08-09 20:22:02
【问题描述】:
我正在尝试将此函数转换为等待 notepad.exe 为通用等待函数(可以等待任何进程)。我不能在不破坏语法的情况下在 sQuery 中添加变量,有什么办法可以绕过这个问题吗?
Function wait()
Set svc=getobject("winmgmts:root\cimv2")
sQuery="select * from win32_process where name='notepad.exe'"
Set cproc=svc.execquery(sQuery)
iniproc=cproc.count
Do While iniproc = 1
wscript.sleep 5000
set svc=getobject("winmgmts:root\cimv2")
sQuery="select * from win32_process where name='notepad.exe'"
set cproc=svc.execquery(sQuery)
iniproc=cproc.count
Loop
Set cproc=nothing
Set svc=Nothing
End Function
Set fso = WScript.CreateObject("Scripting.Filesystemobject")
Set wscr = CreateObject("Wscript.shell")
wscr.Run "notepad.exe"
wait()
MsgBox "done!"
我要疯了!!
【问题讨论】:
标签: vbscript