Is there a batch file command that closes a dialog box?
January 27, 2008 6:14 PM Subscribe
For windows batch files, is there a way to automatically close dialog boxes that open as a result of a windows program producing an error?
I'm struggling trying to write a batch file for windows 2000 which does a variety of things on an hourly basis, one of which is to start a windows program to run.
That program goes out on the internet and makes some checks, and the batch file works fine for that. The problem is when the computer loses an internet connection for some reason, the program cannot complete it's internet check and produces a single dialog indicating it couldn't connect, with one "OK" button on it. At that point the batch file hangs, because I have other events in the batch file which must occur, and they can't complete because I had to use the start and wait switch like this:
Start /wait "" "windows program.exe" /run
which forces the batch file to wait until the window program finishes execution, and only then continues to the next line of the batch file. If I can just get the batch file to automatically close the error dialog, then the batch file can proceed normally as I want.
I'm fairly sure I'll need some sort of IF THEN statement to get this to work, but this is my first time trying to write a somewhat complicated batch file, and I'm not sure about how to integrate an IF THEN statement with some command to close that error dialog if it appears.
Anybody have any experience in batch files and can lend me some ideas?
Thanks.
I'm struggling trying to write a batch file for windows 2000 which does a variety of things on an hourly basis, one of which is to start a windows program to run.
That program goes out on the internet and makes some checks, and the batch file works fine for that. The problem is when the computer loses an internet connection for some reason, the program cannot complete it's internet check and produces a single dialog indicating it couldn't connect, with one "OK" button on it. At that point the batch file hangs, because I have other events in the batch file which must occur, and they can't complete because I had to use the start and wait switch like this:
Start /wait "" "windows program.exe" /run
which forces the batch file to wait until the window program finishes execution, and only then continues to the next line of the batch file. If I can just get the batch file to automatically close the error dialog, then the batch file can proceed normally as I want.
I'm fairly sure I'll need some sort of IF THEN statement to get this to work, but this is my first time trying to write a somewhat complicated batch file, and I'm not sure about how to integrate an IF THEN statement with some command to close that error dialog if it appears.
Anybody have any experience in batch files and can lend me some ideas?
Thanks.
You could have the batch file try to ping a known good host on the internet, then only if it can, run the other program.
Or, give AutoIT a try.. a great scripting language with tons of windows support.
posted by mattdini at 6:29 PM on January 27, 2008
Or, give AutoIT a try.. a great scripting language with tons of windows support.
posted by mattdini at 6:29 PM on January 27, 2008
Does "windows program.exe" happen to have a quite option? Such as /q? Most things that are meant to run from the command line do...
posted by jeffamaphone at 11:04 PM on January 27, 2008
posted by jeffamaphone at 11:04 PM on January 27, 2008
Yeah... seconding autoit. That thing is rad for scripting on windows, especially for dealing with other programs and dialog boxes.
posted by ph00dz at 5:37 AM on January 28, 2008
posted by ph00dz at 5:37 AM on January 28, 2008
Yeah, the simplest solution is to see if that program has a /quiet or a /y type of option that will keep it quiet.
Use the 'start' command to call the program. type start /? to get all the options. This will start whatever program it is and continue processing the rest of the batch file without waiting for the first one to finish.
Example:
notepad.exe
calc.exe
Put that into test.bat and run it. Notepad will run. When you close it, calculator will run.
However:
start notepad.exe
start calc.exe
Will start them both and close the batch window instantly.
And:
start notepad.exe
calc.exe
Will start notepad and calc instantly, but will leave the batch window open until you close calculator.
posted by gjc at 6:26 PM on January 28, 2008
Use the 'start' command to call the program. type start /? to get all the options. This will start whatever program it is and continue processing the rest of the batch file without waiting for the first one to finish.
Example:
notepad.exe
calc.exe
Put that into test.bat and run it. Notepad will run. When you close it, calculator will run.
However:
start notepad.exe
start calc.exe
Will start them both and close the batch window instantly.
And:
start notepad.exe
calc.exe
Will start notepad and calc instantly, but will leave the batch window open until you close calculator.
posted by gjc at 6:26 PM on January 28, 2008
« Older Mystery crown-head must have an interesting story | Ever coming to a theater near me? Newer »
This thread is closed to new comments.
posted by aubilenon at 6:17 PM on January 27, 2008