notes/snippet/vbscript/stop.vbs

18 lines
490 B
Plaintext

REM 文件编码需要使用 ANSI
Set objsws = GetObject("winmgmts:\\.\root\cimv2")
Set colPro = objsws.ExecQuery("select * from Win32_Process where name = 'wscript.exe'")
check = 0
for each objProcess in colPro
if instr(objProcess.CommandLine, "start.vbs") then
check = check + 1
end if
next
if check = 0 then
msgbox "程序未运行,确认退出"
else
Set objShell = CreateObject("Wscript.Shell")
objShell.run "taskkill /f /im wscript.exe", hide
msgbox "关闭成功"
end if