DotNetFactory interface functions – SysProcessExists
Check If a Process Exists in Memory
Parent page: Service Functions – DotNetFactory (QTP, VBScript)
Description
Create an instance of Process object through DotNetFactory – search for local processes by name – return result as boolean.
Note. Name is case-insensitive but no wildcards supported.
Implementation
Public Function SysProcessExists(ByVal sName) Dim objSDP Dim objSDPArr Dim boolRC Set objSDP = DotNetFactory.CreateInstance("System.Diagnostics.Process", "System") Set objSDPArr = objSDP.GetProcessesByName(sName) boolRC = CInt(objSDPArr.length) > 0 Set objSDP = Nothing Set objSDPArr = Nothing SysProcessExists = boolRC End Function
Examples
Dim boolRCboolRC = SysProcessExists("winword") if boolRC Then MsgBox("WinWord is running") End If