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