Last active
August 21, 2024 06:13
-
-
Save codeartery/2459ba6e235b72eba346e192fcf4847f to your computer and use it in GitHub Desktop.
Check if a process is running in VBScript.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Function IsProcessRunning( processNameExe ) | |
IsProcessRunning = GetObject("WinMgmts:\\.\root\cimv2") _ | |
.ExecQuery("SELECT * FROM Win32_Process WHERE Name LIKE '" & processNameExe & "'") _ | |
.Count > 0 | |
End Function |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Function IsProcessRunning( processNameExe ) | |
IsProcessRunning = GetObject("WinMgmts:\\.\root\cimv2") _ | |
.ExecQuery("SELECT * FROM Win32_Process WHERE Name LIKE '" & processNameExe & "'") _ | |
.Count > 0 | |
End Function | |
'Usage | |
If IsProcessRunning("notepad.exe") Then | |
Msgbox "notepad process is running" | |
Else | |
Msgbox "notepad process is not running" | |
End If | |
' Using wildcards | |
MsgBox IsProcessRunning("%note%") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment