0

我正在寻找一个 VBScript,当用户单击它时,它将检查并查看用户是否正在运行该进程winver.exe。如果该进程winver.exe在该用户下运行,它将结束该进程,如果该进程winver.exe未运行,它将继续使用下面的脚本。

Dim objShell
Set objShell = WScript.CreateObject( "WScript.Shell")
const iHideWindow = 0

objShell.Run """C:\Program Files (x86)\Citrix\ICA Client\wfcrun32.exe"" ""C:\APP.ica"""

Set oShell = CreateObject("WScript.Shell")
oShell.Run "winver", 0 
4

1 回答 1

0

WMI 可能是处理此问题的最佳方法:

Set net = CreateObject("WScript.Network")
user   = LCase(net.UserName)
domain = LCase(net.UserDomain)

Set wmi = GetObject("winmgmts://./root/cimv2")
qry = "SELECT * FROM Win32_Process WHERE Name='winver.exe'"
For Each p In wmi.ExecQuery(qry)
  p.GetOwner u, d
  If LCase(u) = user And LCase(d) = domain Then p.Terminate
Next
于 2013-09-23T15:39:25.317 回答