| 1. |
Solve : Batch file - check if program is running and switch to it? |
|
Answer» Are there commands to check if a program is already running, and give an external program focus? Thanks. This seemed to work for me, but what is the command to bring focus or switch to the program?A 3rd PARTY program MIGHT be able to do it, but I doubt it. Batch can't normally do that... appactivate (or something close to that) in a .wsh file may do it...I found it in the MSDN for SendKeys.instead of doing "c:\blah.exe" , you can do "start c:\blah.exe" Launched from cmd or bat, the first waits for blah.exe to finish/terminate. The second SAYS to launch blah in a new window and continue what we're doing.Quote from: uniquegeek on March 31, 2011, 09:42:07 AM instead of doing "c:\blah.exe" , You have revived a two year old thread. i think this can also be a alternative. @echo off tasklist /nh /fi "imagename eq notepad.exe" | find /i "notepad.exe" if errorlevel 0 if not errorlevel 1 goto IsRunning start /b notepad.exe :exit pause exit :IsRunning echo Cannot Have Multiple Interface Process Please Check the... pause exitThis thread was last posted to 3 years ago, and it was created 6 years ago. Just sayin' Hello, I am having a peculiar and specific problem. When I use a batch file to test if, say, "notepad" is working, I use the simple program here: //////// SETLOCAL EnableExtensions set EXE=notepad.exe FOR /F %%x IN ('tasklist /NH /FI "IMAGENAME eq %EXE%"') DO IF %%x == %EXE% goto FOUND echo Not running pause goto FIN :FOUND echo Running pause :FIN //////// And it works, of course. But not if I change the second line to: set EXE=dbase.exe This batch file doesn't see that ol' dBase IV is running when it is running. (I still have the program execute notepad because I don't want the trouble of two versions of dBase fighting over files.) Is there something else I should know about this or is there an alternate test out there? Does this have something to do with running a legacy program like Ashton-Tate's dBase IV? (The program works well except when someone tries to run two versions of it at the same time.) I THANK anyone for their time.Once again...the Thread that will not die... |
|