Can anybody tell me if it's possible to detect if Word is active on a client PC.
I can start Word using the Word type library - as a new task - create a new document ,... but i want detect if there's already an active instance of Word.
May try the script hereinbelow, see if it answers your query.
Get the idea behind and you can therefore modify it to suit your other uses. It is not limited to detect MS Words. Just change the sPattern to other representative applications and it'll run the same.
Dim sPattern, oWMI, Instances, arrayProc, oProc, sProc, separator, i
sPattern = "Winword"
separator = space(1)
Set oWMI = GetObject("winmgmts:" 'for local
sProc = separator : Instances = 0 : sPattern = trim(sPattern)
For Each oProc in oWMI.InstancesOf("Win32_Process"
sProc = sProc & oProc.Description & separator
Next
arrayProc = Split(trim(sProc),separator)
For i = 0 to UBound(arrayProc)
If InStr(1,UCase(trim(arrayProc(i))),UCase(sPattern),1) <> 0 Then
Instances = Instances + 1
End If
Next
If Instances <> 0 Then
MsgBox "The process represented by the pattern [ " & sPattern & _
" ] is running on the local in [ " & cstr(Instances) & " ] instance(s)."
Else
MsgBox "The process represented by the pattern [ " & sPattern & _
" ] is not running on the local."
End If
Set oWMI = Nothing
WScript.Quit
'-----------------------/tsuji/---------
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.