VBS调用并监控记事本进程

Dim flag
flag=true
Set WshShell = CreateObject("WScript.Shell") '创建WScript.Shell对象
    Set oNotepad = WshShell.Exec("notepad") '运行记事本
    WshShell.AppActivate oNotepad.ProcessID '激活记事本

set bag=getobject("winmgmts:\\.\root\cimv2") 

do while flag
flag=false
set pipe=bag.execquery("select * from win32_process where name='notepad.exe'") 
For each id in pipe
    flag=true
Next
WshShell.SendKeys "A"

wait 1
'Exit do  跳出循环
loop

posted on 2014-03-10 17:08  上海—Michael  阅读(453)  评论(0)    收藏  举报