Solved

Easy batch file question?

Posted on 1998-07-10
22
234 Views
Last Modified: 2013-12-03
I want to enter a command in a batch file that closes the window when the program is done. Just like in a shortcut pif file that allows me to check the "Close on Exit" box. Is there a way to do this. "Exit" does not work.
0
Comment
Question by:alavan
  • 7
  • 6
  • 3
  • +4
22 Comments
 
LVL 6

Expert Comment

by:alamo
ID: 1409879
How are you running the batch file?
0
 

Expert Comment

by:jruesch
ID: 1409880
Use the "exit" command.
0
 

Expert Comment

by:jruesch
ID: 1409881
Use the "exit" command.  I just tested it and it works fine in both win95 and winnt.
0
 
LVL 1

Author Comment

by:alavan
ID: 1409882
If I create a batch file, leave it on the C: drive, go back to the desktop, open Windows Explorer and double-click the .bat file, the program runs and even indicates "Finished" on the Title Bar, but the MS-DOS box remains open. I want to close the box. The batch file runs nightly and when the PC is left unattended (most of the time) we end up with a bunch of MS-DOS boxes all over the screen.

I want to close the box.
0
 

Expert Comment

by:jruesch
ID: 1409883
I just did exactly that with a test file.  A batch file that ends in the command EXIT.  Click on it in explorer to open it, a window opens and the file runs, exit is then executed and the window closes.  I am wondering if your functions within it are ending abnormally and the batch file is not continuing to run to the exit line.  Try the following test: make a batch file that contains some easy simple command (like a dir) and then an exit on the last line, save it.  Try to run it as you outlined and see if it doesn't close the window.  If it doesn't, what version of windows are you running?  winnt 3.51, winnt 4.0, win95 .0, win95 A, win 95 B, etc...  If you are running win95 (the orginal version) with fixes, try putting on Service Pack 1.  
0
 
LVL 6

Expert Comment

by:alamo
ID: 1409884
jruesch, I think if you take the "exit" out of your test file it will still close, the "exit" isn't necessary and doesn't make the window close. and as alavan originally said:
>"Exit" does not work.

Something else is happening here.
0
 
LVL 6

Expert Comment

by:alamo
ID: 1409885
Alavan, when the window says "Finished" click on the icon in the upper left corner and select "properties".... somewhere there should be a "Close on Exit" checkbox which controls this behavior.
0
 
LVL 1

Author Comment

by:alavan
ID: 1409886
Thank you all for your suggestions. I just got back into the office. I'll have to revisit this on Monday. See you then.

Have a nice weekend.
0
 
LVL 11

Expert Comment

by:alexo
ID: 1409887
Add "cls" (without the quotes) as the last line in the program or immediately befor the "exit".
0
 
LVL 11

Expert Comment

by:alexo
ID: 1409888
s/befor/before :-)
0
 
LVL 5

Expert Comment

by:tuvi
ID: 1409889
It is easier to create a shortcut PIF file to the BAT file and choose close on exit. You don't have to create it, the first time the BAT file is run, Windows will automatically create it for you.
0
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
LVL 1

Author Comment

by:alavan
ID: 1409890
Alexo,  I'm not sure what your answer means. "s/befor/before" ?

Everyone, unfortunately my scheduling program won't let me execute either a shortcut or a pif file. When I enter the shortcut, it converts the name from .pif to .bat. Maybe there's no way to do this due to the fact that it's the window giving me issues and we're trying to close the window from DOS. Any more ideas.
0
 
LVL 11

Expert Comment

by:alexo
ID: 1409891
My answer says: Add "cls" (without the quotes) as the last line in the program or immediately befor the "exit".

Then I niced a spelling mistake and suggested correcting it by substituting "before" for "befor".

Have you considered trying the "cls" suggestion before rejecting my answer?  It works, you know...
0
 
LVL 1

Author Comment

by:alavan
ID: 1409892
Alexo, the box still stays open even after cls. The screen clears, the exit command executes, then the box stays open.
0
 
LVL 11

Expert Comment

by:alexo
ID: 1409893
Curiouser and curiouser...
What is your OS?  95 or NT?
0
 
LVL 3

Expert Comment

by:Norbert
ID: 1409894
Hi I just had a look to a bat file on my Win 95 system
clicked the right mouse button on it and select properties
a Property dialog opend with 6 tabs.
The second one is titeld with Program (it is the german version but I guess its same titled in english version)
There is near the bottom line a check box titeld (in german) 'Beim beenden schliessen' what means close window if program has finished if this box is checked my batch files will close on exit if not checked they do not close and only show inside the title bar that they are finished so checking these check box should close the window
0
 
LVL 11

Expert Comment

by:alexo
ID: 1409895
I believe Norbert's suggestion will create a PIF file.
0
 
LVL 1

Author Comment

by:alavan
ID: 1409896
Norbert, the properties you are looking at are actually the .pif properties (that the Windows shell uses) of the .bat file. The batch file itself has no properties other than executing the DOS commands therein.

Alexo, I'm using Win95B. Maybe I need to look into a better scheduling program that'll let me execute Shortcuts and .pif's?
0
 
LVL 11

Expert Comment

by:alexo
ID: 1409897
alavan, have you tried creating a PIF file for the batch file?  I may be wrong but I think Win95 will automatically consult the PIF file when the batch is run.

Another option is to set up a default PIF file (windows\_default.pif) to do what you want.

Some references:
  http://www.dejanews.com/getdoc.xp?AN=204069982
  http://www.dejanews.com/getdoc.xp?AN=236623973
  http://www.dejanews.com/getdoc.xp?AN=258897995
  http://www.dejanews.com/getdoc.xp?AN=258897749
  http://www.dejanews.com/getdoc.xp?AN=261758183
  http://www.dejanews.com/getdoc.xp?AN=292293661

0
 

Expert Comment

by:ewilson
ID: 1409898
I have the exact same problem with a VB program I wrote that creates and then runs a batch file.... I'm also running 95b... when the Batch file finishes does it print a message on your screen that says "your pop up program is now ready to run when you have finished press ctrl-c to return to windows".   I have tried executing a ctrl-c within the bat file but that occurs to soon.  This message seems to come up for me whenever i execute a batch file directly from windows bypassing the pif file.  Hopefully these guys can help, I know i'll be watching for their answer.
0
 
LVL 11

Accepted Solution

by:
alexo earned 50 total points
ID: 1409899
Got by email:
>> Your last response worked But, in a special implementation. Submit it as a proposed answer instead of a comment, so I can give you the points. I'll also tell you the details in a comment.

OK, The answer refers to my comment from "Tuesday, July 14 1998 - 01:26PM PDT"
0
 
LVL 1

Author Comment

by:alavan
ID: 1409900
It works Alexo! In order for the batch file to use the .pif file (shortcut) upon execution, the .pif file needs to be in the exact same directory as the .bat file. Once the .bat file is executed, it refers to the .pif file for property settings.

Creating the .pif (MS-DOS name) or shortcut (Win95 name) alone doesn't do it. I had to place it in the same directory.

It works. Took some clarification, but it works. Thank you all for your suggestions.
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

This article shows how to make a Windows 7 gadget that accepts files dropped from the Windows Explorer.  It also illustrates how to give your gadget a non-rectangular shape and how to add some nifty visual effects to text displayed in a your gadget.…
zlib is a free compression library (a DLL) on which the popular gzip utility is built.  In this article, we'll see how to use the zlib functions to compress and decompress data in memory; that is, without needing to use a temporary file.  We'll be c…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now