我想用vbs杀死一个进程,我知道命令是:
oShell.Run "taskkill /im software.exe", , True
Run Code Online (Sandbox Code Playgroud)
在我们杀死它之前如何获取software.exe路径?
因为我想再次启动software.exe.
WMI(也可以终止):
dim wmi, list, process, path, shell
set wmi = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
set list = wmi.ExecQuery("Select * from Win32_Process")
'// or "Select * from Win32_Process where name = 'xxxxxxx.exe'" allowing the removal of the if block
for each process in list
if (lcase(process.name) = "xxxxxxx.exe") then
path = process.ExecutablePath
process.terminate()
exit for
end if
next
wscript.echo path
set shell = CreateObject("WScript.Shell")
shell.Run Chr(34) & path & Chr(34)
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
2707 次 |
最近记录: |