Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Identify a running app

Status
Not open for further replies.

TheStoneman

IS-IT--Management
Nov 29, 2007
5
US
Please help. Is there a way to determine if a particular app such as Microsoft Access is currently running? The AppActivate method says that it returns a boolean value whether the call to the app was successful or not. I am not able to figure out how to query that value. Thanks.
 
figure out how to query that value
A boolean value is either True or False.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
I understand what a boolean value is. How do I get a variable I can test to contain the value?
 
Figured it out.

Success = WshShell.AppActivate("Microsoft Access")
If Success = False Then WScript.Quit

Documentation isn't very good in this area. Found it by scouring the net.
 
I think a better way though not as concise would be to use WMI to check for the running process.

Code:
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colProcesses = objWMIService.ExecQuery _
    ("Select * from Win32_Process Where Name = 'MSAccess.exe'")

If colProcesses.Count = 0 Then
    Wscript.Echo "Access is not running."
Else
    Wscript.Echo "Access is running."
End If

Big advantage this has over your method is that by replacing the period with a machine name in the strComputer = "." you can check a remote system.

I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
Work SMARTER not HARDER. The Spider's Parlor's Admin Script Pack is a collection of Administrative scripts designed to make IT Administration easier! Save time, get more work done, get the Admin Script Pack.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top