gpt4 book ai didi

vbscript - 使用VBS获取进程路径

转载 作者:行者123 更新时间:2023-12-02 22:14:06 26 4
gpt4 key购买 nike

我想用vbs杀死一个进程,我知道命令是:

oShell.Run "taskkill /im software.exe", , True

在杀死 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)

关于vbscript - 使用VBS获取进程路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30646079/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com