Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

AUTOMATICALLY CLOSE BATCH FILE!!! 3

Status
Not open for further replies.

SPYDERIX

Technical User
Jan 11, 2002
1,899
CA
Hi,

How do I close this batch file automatically when it's finished.

This is my batch file for deleting tif, cookies, etc.
------------------------
cddeltree/y temp
cd windows
deltree/y cookies
deltree/y history
deltree/y temp
deltree/y win386.swp
cd recent
DELTREE /y c:\windows\recent\*.* > NUL
cdcd windows
cd tempor~1
deltree/y content.ie5
cdcd windows
md temp
---------------------

I want the batch file to close automatically when the batch file finishes. I have tried putting exit at the end, but that didn't work. I'm using Windows ME.

Thanks
[deejay]
Nate
"If you're not living on the edge, you're taking up too much space!"
 
Did you try right-clicking on the batch-file , properties , program and checking the 'Close on Exit' (?)
 
No I didn't do that! I have now and it works perfectly. Thanks! [deejay]
Nate
"If you're not living on the edge, you're taking up too much space!"
 
Nate

Nate, its supposed to run from DOS, after minimal boot.
You cannot delete win386.swp file from Windows.
That being true, having it "close on exit" is a waste of time... smitee
 
What about setting the minimum virtual memory to 0 (so as to get it deleted at startup) ?
 
Why are you running this while Windows is running.
Looks to me that you should let this run at startup
as part of your autoexec.bat ?
 
FLASHTAG,

How do I add this to autoexec.bat. Do I put it before evrything that's already there, or after it?

Thanks! [deejay]
Nate
"If you're not living on the edge, you're taking up too much space!"
 
Either!! It doesn't really matter, but my advice would be to put it after the other commands, so that they can load first. But either way it should still work.
 
It depends on what you have in autoexec.bat.
I would put it at the end. Every time you start
your pc all your files that you want del will
happen at startup. At the end of the the file run
Windows should start. If not then at the vary end
of your autoexec just put " win " no quotes.
I would be vary careful and make sure you type
your commands Right. I myself don't think you should
run these commands unattended.
 
This is what is in my autoexec.bat file:
-----------------------
SET windir=C:\WINDOWS
SET winbootdir=C:\WINDOWS
SET COMSPEC=C:\WINDOWS\COMMAND.COM
SET PATH=C:\WINDOWS;C:\WINDOWS\COMMAND;C:\PROGRA~1\DELL\RESOLU~1\COMMON\BIN
SET PROMPT=$p$g
SET TEMP=C:\WINDOWS\TEMP
SET TMP=C:\WINDOWS\TEMP
----------------------- [deejay]
Nate
"If you're not living on the edge, you're taking up too much space!"
 
OK, thanks alot!
colorado1.gif

"Quest for the Cup - 2002!"
 
FLASHTAG,

That didn't work. I enter my batch file stuff to the end of autoexec.bat, and saved it then restarted, and the TIF etc. weren't emptied/deleted, and the autoexec.bat file was reverted back to the original, and my stuff was deleted.

Any reason as to why this won't work?

Thanks again.
colorado1.gif

"Quest for the Cup - 2002!"
 
If the TIF etc. weren't deleted, that indicates that the revised autoexec.bat did not run/was not properly saved.
If you add one or more pause statements in the autoexec.bat (say one after the original lines and one after deleting the TEMP directory) , then you will see if there is any error message related to the del command.
The autoexec.bat is supposed not to be hidden, system file or with read-only attribute.
 
*.tif are image files. Y are you deleteing them and
in what diectory are they in. I agree with PAndersen
add some pause after the commands and you then look
for any errors that pop up.
 
NOT .TIF, but T.I.F.(Temporary Internet Files).

PAndersen, are you saying that I should add PAUSE after the autoexec stuff and then again at the very end. I used edit to modify to file, and then saved it. Then re-opened it and everything was there, but then disappeared after I re-started.
colorado1.gif

"Quest for the Cup - 2002!"
 
Nate!

I would caution you against part of your batch file:

If you install new software, that parks little files it needs in the Windows Temp folder, and then that software requires a reboot, you might just trash the files it needs, before it can get to them...I have had this happen with Microsoft products, that update the Windows Installer first, then reboot on the new installer before finishing the software install - one such program is MS Office 2000..just a caution!!!

[pc3] Rich
prescot9@hotmail.com
Father, Geek, and MCP
 
Try the following to see if it helps:

Place the following lines in a New batch file and remember the name of the file

++++++++++++
cd deltree /y c:\temp
deltree /y c:\windows\cookies
deltree /y c:\windows\history
deltree /y c:\windows\temp
deltree /y c:\windows\recent\*.* > NUL
deltree /y c:\windows\tempor~1\content.ie5
md c:\windows\temp
++++++++++++

use "explorer"/"my comp" to locate bat file and change the properties to "close on exit".

Click start > settings > task bar and start menu > "advance" tab > "add" button.

Now "browse" for the link file that was created when you changed the properties and add it to the Startup folder.

Once, it's added, test it out by clicking start> programs> startup> (batch file link). If this is successful, the next step is to actually do a re-boot.

Let us know how this turns out. --MiggyD

Never be afraid to try something new. Remember that amateurs built the Ark. Professionals built the Titanic.
 
Good idea from MiggyD ! - In a batch file, you can add PAUSE statements if you wish the program to stop temporarily, and restart when you press any key. In your case, the problem seems to be that the changes made to autoexec.bat will be deleted at restart. That is a feature of WinME. In that version of Windows, you must edit the registry to change the autoexec.bat permanently.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top