PDA

View Full Version : Checking for an Active Application



Rayen
04-23-2001, 09:27 PM
Does anyone know how to use WSH to check if a perticular application is open? I'm writing a script where I want to check if the program is open and if so bring it the foreground else run the program. Thanks a ton.

prasad
07-10-2001, 04:14 PM
Hi
WshShell object provides one method AppActivate
in that you can give the title of the appication you are running.If the application is there focus has been set to that application and the method will return true.Otherwise the method will return false.
Let me know whether this solution has worked or not.
Regards,
Prasad

kevingann
10-24-2001, 11:08 PM
Hi,

I'm attempting to do sort of the same thing. I'm running test applications, and I'm struggling with getting the script to wait until the application is done to go on to the next step. So far I've just tried using Wscript.Sleep <time>, but as you probably know this a pretty lame solution. :) I get the impression the AppActivate will bring a named application window to the forefront, but if I'm understanding correctly, you say that this can be used in a conditional statement? If I'm understanding correctly... 1) If AppActivate returns 0 it has succeeded therefore my application is still running, and 2) If AppActivate returns 1 it has failed and therefore my application isn't running anymore?

Thanks!

balasyp
04-03-2002, 10:47 AM
set test = createobject("wscript.shell")
test.run "c:\test.exe",1, true

the "true" at the end of the second line means wait untill "teszt.exe" finished and just after that continoue with the next statement..

BPeter

Jama
04-03-2002, 06:46 PM
There is a way to check if a particular application is open on not. I wrote some code that will check weather notepad is running or not and then start Excel.
It uses the win32_process to get the process and it’s ID. It can then shut it down if you wish.

Take a look at the code here;

http://www.winguides.com/forums/showflat.php?Cat=&Board=brdScripting&Number=43573&page=0&view=collapsed&sb=5&part=

I got the core code from the following web page, they have a good help section, take a look at it;
http://content.communities.msn.com/WindowsScript/faq.msnw


Jama