Saved Bookmarks
| 1. |
Solve : Waiting to terminate?? |
|
Answer» How can I make a batch file wait for a GUI application to close. Start /wait doesn't work with GUI applications (note the bolded text). Starts a separate window to run a specified program or command.Although it says that it won't occur in the command script (bat file), it won't wait.In my testing 'start /wait notepad.exe' waits until notepad exits to continue. try it Quote from: uSlackr on May 27, 2009, 10:42:19 AM In my testing 'start /wait notepad.exe' waits until notepad exits to continue. try itStart /wait firefox.exe does not wait. start /wait firefox.exe works for me as expected under Vista Quote from: uSlackr on May 27, 2009, 03:42:00 PM start /wait firefox.exe works for me as expected under VistaTry this and see...It only waits for it to load. echo off echo 1 start /wair firefox.exe echo 2 pauseHelpmeh is right, start /wait doesn't wait for termination of any GUI program. I forget the specifics but you'll need to write a program specifically for this. using some goofy convolution of createProcess(). just start the process, and then call WaitForSingleObject() on the ProcessID.you could also make a loop to test to see if the process is still active. if the process is active wait and check again. Code: [Select]echo off set appName=firefox.exe start /wait %appName% echo.App is running... tasklist |findstr %appName% >nul && call WAIT echo.App in not running... pause :WAIT tasklist |findstr %appName% >nul || exit /b ping -n 1 -w 1000 1.1.1.1 >nul goto WAIT sth like this ?That would only work on computers with tasklist, of course you could put tasklist into the same ZIP as the batch script.. Quote from: macdad- on May 28, 2009, 12:24:22 PM That would only work on computers with tasklist, of course you could put tasklist into the same ZIP as the batch script..Which is XP PRO and possibly Vista...I have Home edition...but I could get tasklist...This worked for me. I am on a PC running XP Pro. Code: [Select]echo off start /wait firefox.exe echo on Quote from: TheHoFL on May 29, 2009, 11:12:07 AM This worked for me. I am on a PC running XP Pro.echo off echo 1 start /wait firefox.exe echo 2 pause Try that. It is supposed to wait until firefox closes...it only waits until it finishes loading."When executing an application that is a 32-bit GUI application, CMD.EXE does not wait for the application to terminate before returning to the command prompt." The above specifies one exception - " This new behavior does NOT occur if executing within a command script." Perhaps there are other exceptions yet to be declared. Firefox breaks the rules. Is it a proper 32 bit GUI ? I have just launched two instances of Firefox, and two of Notepad. Windows Task Manager reports two instance of each on the "Applications" tab and two Notepads but ONLY ONE Firefox on the "Processes" tab. Incidentally, when all Firefox instance are closed, they disappear from the Applications Tab, and normally the Firefox process also shuts down, but sometimes it gets stuck and then CCleaner is unable to clear the Firefox cache until Task Manager has been launched and the Firefox process selected and terminated. I think Firefox is not a suitable choice for evaluating what happens with "normal" software. I am puzzled - what is meant by " This new behavior does NOT occur if executing within a command script." What was the OLD BEHAVIOUR that differs from the "new behavior" ? Was it to wait for termination regardless ? Was it to NOT wait for termination regardless ? Was it that waiting was not subject to a 32 bit GUI restriction ? What is "32-bit GUI application" ? Does this apply to both windowed application and console application. Does the above only apply when the /WAIT option is used ? Or does it apply regardless (since this whole condition is not indented under the /WAIT description) ? Regards Alan Quote from: ALAN_BR on May 30, 2009, 04:01:43 PM but ONLY ONE Firefox on the "Processes" tab.I get 1 per open window... If you right click on each open task, and select go to process, it should give you more than one process. Quote from: ALAN_BR on May 30, 2009, 04:01:43 PM I think Firefox is not a suitable choice for evaluating what happens with "normal" software.I'm not trying to evaluate "normal" software, I'm trying to wait for firefox to terminate. The quote I got from the command prompt (and my testing too), implies that start /wait will not wait for firefox to terminate, which is what I am trying to ACCOMPLISH. |
|