2013-09-23 342 views
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 

回答

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