利用vbs写的延时关闭ie进程的脚本代码
程序员文章站
2022-04-29 09:20:26
复制代码 代码如下: delay = 5000 strcomputer = "." set objwmiservice = getobject("winmgmts:{imp...
复制代码 代码如下:
delay = 5000
strcomputer = "."
set objwmiservice = getobject("winmgmts:{impersonationlevel=impersonate}!\\" & strcomputer & "\root\cimv2")
set objstartup = objwmiservice.get("win32_processstartup")
set objconfig = objstartup.spawninstance_
set objprocess = getobject("winmgmts:root\cimv2:win32_process")
errreturn = objprocess.create("c:\program files\internet explorer\iexplore.exe http://www.jb51.cn", null, objconfig, pid)
if errreturn = 0 then
wscript.echo "process id is: " & pid
end if
wscript.sleep delay
set colprocesslist = objwmiservice.execquery("select * from win32_process where processid = '" & pid & "'")
for each objprocess in colprocesslist
objprocess.terminate()
next
wscript.echo "close processid = '" & pid & "'"
将上面保存为 1.vbs
运行方法,在cmd 里面
cscript 1.vbs
看效果