//flex table opened by JP

Click to See Complete Forum and Search --> : Closing a DOS window in NT?


OuTpaTienT
04-04-2000, 03:31 PM
At work I have written a tiny batch file that deletes and recopies a specific file that we use on a daily basis.

On our machines with Win98, this batch file runs flawlessly, then closes the window with no user input. However, on the NT machines, the shortcut to the batch file does not have the "close on exit" option. Is there any way to run a batch file and make it automatically close the window when finished on an NT machine?

OuTpaTienT
04-04-2000, 06:51 PM
Oh come'on. You guys are dissapointing me here. Someone must have a clue. ?

1Kahuna
04-04-2000, 07:27 PM
Edit the batch file & add > CLS to the bottom of this file?

happyhamster
04-04-2000, 09:41 PM
I don't have NT right now to test it, so this is only a guess. First, try adding "exit" command at the end of the batch file. Second, try launching the batch file with /c option: cmd /c filename.bat

OuTpaTienT
04-04-2000, 11:24 PM
Hey happyhamster, brilliant minds must think alike http://www.sysopt.com/forum/wink.gif, the first thing I tried is the "exit" thing. That didn't work.

I got tommorrow off, so I gotta wait till Thursday to try the other things. I let ya know if I find something that works.

[This message has been edited by OuTpaTienT (edited 04-04-2000).]

qball
04-05-2000, 09:02 AM
I tried three different batch files. All three closed the DOS box when double clicked from Explorer. Only the third one closed the DOS box when run from Command Prompt (DOS box). Hope this helps.

close_me1.bat
rem doesn't close window from command prompt
dir
close
---
close_me2.bat
rem doesn't close window from command prompt
dir
quit
---
close_me3.bat
rem does close window from command prompt
dir
exit

Win95/98 can be a lot trickier. You refer to the 'Close on Exit' check box. That exists on a shortcut to the batch file, not the file itself. Creating or having that shortcut exist may be problematic. The only way I have found is by suppressing all screen output (@echo off and redirection ) and using exit as the last line of the batch file.

something like;
@echo off
rem does work from command prompt
dir > junk.txt
exit

All output needs to be suppressed including commands.

[This message has been edited by qball (edited 04-05-2000).]

OuTpaTienT
04-05-2000, 10:12 AM
Wow. Thanks qball. Um, I'm still a little unclear though. (Usually I'm kinda bright, but when I'm slow...I'm really slow. http://www.sysopt.com/forum/smile.gif)

For 98, just checking the "close on exit" box in the shortcut to the batch file works fine. But for NT, are you saying I shouldn't use a shortcut to the batch file, but should have the batch file right on the desktop? And then the "exit"/"close"/"quit" will work?

I don't have an NT machine availible to test, or I'd answer that myself. When I'm back at work tomorrow I guess I'll find out.

My batch file is just a couple lines, and all it does is nuke a current file and replace it with a fresh copy before executing it.

Here's all that's in the batch file:

del c:\universe\bin\tc2.exe
copy c:\universe\bin\tc.exe c:\universe\bin\tc2.exe
start c:\universe\bin\tc2.exe

OuTpaTienT
04-05-2000, 10:18 AM
Ok, I think I got it. Thanks for the help qb.