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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Check to see if apps is running 1

Status
Not open for further replies.

kweh4

Technical User
Aug 8, 2001
33
US
Hello,

I am new to scripting and have a major task that was handed to me by my bosss. I need to write a script that will control two applications. Only one of these apps should be allow to run on the user box at any given time. If the user click/open app 1, the script should check to see if app 2 is already open and prompt the user to closed app 2 before running app 1. It should work the other way around app for app 2. In the process, the script should prevent the second app from running until the current app has been closed. Any reference material will be helpful thanks.

MCSE 2000
Computer Engineering Technology
 
Do a search in this forum for wmi process execquery

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Can you please be more specific. The wmi process execquery did that return anything useful when I entered it in the search bar above and asked to search post. The close I have come across was a user wanting wanting to pop-up box on word, powerpoint, and excel. If someone can provide a link to relevent info that will help out alot. Thanks PHV.

MCSE 2000
Computer Engineering Technology
 
If I'm understanding you correctly, you will need code to check if applicationX is running - here is some code.

Code:
Set WshShell = WScript.CreateObject("WScript.Shell")

Set locator = CreateObject("WbemScripting.SWbemLocator")
Set service = locator.ConnectServer()
Set props = service.ExecQuery("select name, description from Win32_Process where name = 'program.exe'")
num = props.Count

If num > 0 Then
   'Program is running
Else
   'Program is not running
End If

Set WSHShell = Nothing

From here...



All hail the INTERWEB!
 
This is a good starting point RhythmAddict112 and thanks for it. Now, I want to take this a step farther. This script only check to see if a given app is running. I want a script that will do this when the user try to open a second app. For example the user should get a dialog box that said "please closed Excel before running PowerPoint." Powerpoint should not be allow to run until the user has close Excel. Also, from what I see, the user will have to doube click the script everytime. I want the script to run in the background, monitoring both apps without the user input or awareness.

Thanks again for you help.

MCSE 2000
Computer Engineering Technology
 
From the limited amount of information/requirements I've got from you it sounds to me like you may want to explore some other option besides scripting. You're going to need to monitor if ProgramX is running and if so ProgramY can't run - you're going to need to do this the entire time the machine is on? Is that correct? What are the exact programs you're looking for? You may want to be looking into creating a service, instead...



All hail the INTERWEB!
 
Our sales team is constantly on the road and have to rely on vpn to access resources within the organization. There are two dabase programs that they use frequently. We learn recently that those two apps can't run simutanously on their laptop or they will have a problem. That is why our system analyst told me to write a script that will resolved this. He is the script guru and have too much on his plate to work on this one. However, given that I am new to the department and to scripting, it will not reflect too well on me to throw the towel in this early. Can this problem be resolved through scripting?

Thanks alot.

MCSE 2000
Computer Engineering Technology
 
Perhaps I'm readin too into this...It seems like it would be a lot simpler to do somethin like this...

- Change the shortcut to DB program1.exe to point to a scriptA.vbs

- scriptA.vbs will naturally launch when the shortcut is clicked - in it, it will have code similiar to the code I posted earlier...To check if Program2.exe is running, if it isn't it will launch program1.exe - if it is, then it'll notify the user with a dialog box.

..The same would go for program2.exe's shortcut. Of course, it check if program1.exe was running, instead.

..this way, the script doesn't constantly have to be running.

..the problem with this, is that you'd have to have the shortcuts' target changed on all sales' team memebers laptops. However, you could probably set up another vbs script to change that....shouldn't be a big issue to work through that.



All hail the INTERWEB!
 
RhythmAddict112, you're da man! This is what I am going to do. Thank you.

MCSE 2000
Computer Engineering Technology
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top