Web Hosting Talk







View Full Version : Windows batch files


mesobob
02-17-2007, 03:05 PM
I`m running a series of batch files in windows XP pro, every day. Problem is, I cannot seem to find a way of closing the cmd window when the batch file finishes running.

After a few days, I end up getting a screen full of cmd windows because a new one opens on top of the previous one!!

I tried "exit", but the window remains. I read somewhere the exit command does not work in windows xp?

Thanks.

dkitchen
02-17-2007, 03:52 PM
What are the commands you're running? The windows should close themselves once the command is completed, unless the command was initiated on the command line itself. I know this is the case with logon scripts, etc.

Dan

Lightwave
02-17-2007, 03:59 PM
How are you calling the batch/cmd file?

You shouldn't do something like cmd.exe /c file.bat
you should just execute file.bat

Lightwave
02-17-2007, 04:34 PM
After doing some testing.. I cant actually make it not close no matter what I do :P so I'm not sure how you're getting it stuck :p

You might also try using "exit /b" instead.

mesobob
02-17-2007, 04:36 PM
This is the first batch file I`ve ever written, so you`ll have to excuse the mess!!!


start C:\IRS_2.1\runIDV C:\IRS_2.1\IRSscripts\gsenhanced.ids
exit


I`m running the above batch file from the windows scheduler once a day. The application is actually mapping software, which is opened via a bat file, the second line is a script for the software.

The above batch file works, either by clicking it or from the scheduler but once the application and script have finished the window remains open.

Lightwave
02-17-2007, 05:19 PM
Is there any particular reason you need to use "start"?

Removing that might solve your problem as it's forking a sub cmd.exe shell to execute runIDV in.

Lightwave
02-17-2007, 05:21 PM
Is there any particular reason you need to use "start"?

Removing that might solve your problem as it's forking a sub cmd.exe shell to execute runIDV in.

Unless you left stuff out of your script.. I'm not sure why you even need to put all that in a .bat/.cmd file. You should just have your scheduler execute:

C:\IRS_2.1\runIDV C:\IRS_2.1\IRSscripts\gsenhanced.ids

oops i thought i hit edit not quote :p

mesobob
02-17-2007, 08:08 PM
It was the "start" command. Now I wonder why I put that in there!!!

Thanks a lot man!