我需要一个VBScript来检查特定用户是否正在使用某个进程:
代理点击程序图标 - > progcheck.vbs的批处理文件调用 - >
progcheck.vbs看起来只是在那个用户下运行"whatever.exe" - >
如果程序在该用户下运行,那么MsgBox"程序运行" - > wscript.quit(这需要终止批处理文件)
else - >返回批处理文件.
我已经在批处理文件中使用tasklist尝试了这个并且脚本可以工作,但是为域用户运行需要永远.想要在vbscript中这样做.
*** 带有MODS 10/12的更新的脚本 *****
OPTION EXPLICIT
DIM strComputer,strProcess, strUserName,wshShell
Set wshShell = WScript.CreateObject( "WScript.Shell" )
strUserName = wshShell.ExpandEnvironmentStrings( "%USERNAME%" )
strComputer = "." '
strProcess = "notepad.exe"
IF isProcessRunning(strComputer,strProcess,strUserName) THEN
If MsgBox ("Notepad needs to be closed.", 1) = 1 then
wscript.Quit(1)
End If
END IF
FUNCTION isProcessRunning(BYVAL strComputer,BYVAL strProcessName,BYVAL strUserName)
DIM objWMIService, strWMIQuery
strWMIQuery = "Select * from Win32_Process …Run Code Online (Sandbox Code Playgroud)