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:\. ootcimv2") 

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

原文地址:https://www.cnblogs.com/duyy/p/3592189.html