Dim fso,num,flag
flag=true
set bag=getobject("winmgmts:\\.\root\cimv2")
Set fso=CreateObject("Scripting.FileSystemObject")
Set
WshShell=WScript.CreateObject("WScript.Shell")
‘if
fso.FileExists("hello.txt") then
‘set
sfile=fso.getfile("hello.txt")
‘sfile.attributes=0
‘sfile.delete
‘end
if
‘Set TestFile=fso.CreateTextFile("hello.txt",Ture)
‘Set
a=fso.opentextfile("hello.txt",1,true)
‘WshShell.Run
"hello.txt"
WshShell.run "notepad"
num=1
while
flag
WScript.sleep 2000
WshShell.SendKeys num
WshShell.SendKeys
"{TAB}"
WshShell.SendKeys "{TAB}"
WshShell.SendKeys
"A"
WshShell.SendKeys "{ENTER}"
num=num+1
flag=false
set
pipe=bag.execquery("select * from win32_process where name=‘notepad.exe‘")
For each id in pipe
flag=true
Next
wend
set fso=nothing
set
WshShell=nothing
原文:http://www.cnblogs.com/duyy/p/3593303.html