Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
I need a batch file that will run CCleaner and then reboot my pc.
Here are the target lines for each:
"C:\Program Files\CCleaner\ccleaner.exe"
C:\WINDOWS\RUNDLL32.exe shell32,SHExitWindowsEx 2
Thanks for any help. I have tried to do this but can't get it right.
Take Care
Deke

"C:\WINDOWS\RUNDLL32.exe shell32,SHExitWindowsEx 2"
Is that supposed to reboot?
=====================================
If at first you don't succeed, you're about average.M2

Yes. Since I had problems with the W98SE shutdown problems a long time ago I keep and icon on my taskbar with that in the target line to reboot and one for a complete shutdown.
Take Care
Deke

Hi Deke - long time no see
I am just thinking aloud. Not knowing the symptoms you were getting I wonder if it was moving onto the restart before it had finished running cc.
Maybe something along these lines would work:
start /w "C:\Program Files\CCleaner\ccleaner.exe"
start C:\WINDOWS\RUNDLL32.exe shell32,SHExitWindowsEx 2
DerekW

Hi Derek. I have been keeping low on the radar.
CC is running great I just wanted to get the reboot after CC ran so it would then delete the "Files Marked for deletion". These are the TIF files and is normal for CC.
Can I save that as a .bat file in notepad to get it to work?
Take Care
Deke

I haven't tried it (which says all) but sure, just saving it in NotePad should run it if it can. I would normally add @echo off as the first line to get shot of all the verbiage in the DOS box, so it's:
========================
@echo off
start /w "c:\program files\ccleaner\ccleaner.exe"
start c:\windows\rundll32.exe shell32,SHExitWindowsEx 2
========================Note unseen space before the 2 due to turn round on here. Case is unimportant.
DerekW

Thanks Derek
I saved it and put a shortcut on my dekstop,(which comes out as a MSDOS icon). The only thing I had to add was the /Auto command to both the bat and the ccleaner target to get it to go through the entire cleanup and reboot.
You are still "The Man".
Hope you have a great year ahead.
Take Care
Deke

Derek
One other thing I would like to happen when it reboots is to delete the win386.swp file which I have to do now in DOS. Don't know if this can be done on a normal reboot.
Take Care
Deke

This leads to a bit of a dilema. It can't obviously be done before boot and whatever way you look at it your batch file will no longer function once it leaves windows to do the reboot. You could run it from DOS obviously (in short file name form) but this kinda defeats your objective.
You could tackle this another way and put a line to delete win386.swp in your autoexec.bat file (although again I've never tried it). It would then delete it on every boot-up.
There are two possible locations for win386.swp depending on whether you are managing your own swap file or not. If you let windows manage it then it's in c:\windows but if you are a DIY type then it is c: but with a possible zero bytes file which sometimes arrives in c:\windows (which is of no interest).
You can either choose whichever path is appropriate or delete both (to allow for either possiblity), in which case you add these two lines into autoexec.bat:
del c:\win386.swp
del c:\windows\win386.swpBeing a very careful person I would advocate first popping your current win386.swp into some spare folder with a short name (less than 8 characters) on the C drive so that it is easy to get to and copy back from DOS in the most unlikely event that this idea when tested should backfire and you are unable to boot. Fine to dump the copy once you are happy it all works.
DerekW

I added the following to my autoexc.bat and on start up it shows to erase the .swp file. Although it always shows 80mb after deleting or erasing I assume that is just reserved space and not actual content of the file.
#erase c:\windows\win386.swp
I took the # symbol off as it was showing a bad command or file with it there and now shows to perform the erase on reboot.
I don't know if there is much difference between the del and erase command so will try the erase one for awhile.
This whole thing might seem a case of overkill but I did some research and some of the stuff CCleaner deletes is also contained in the .swp file.
Thanks again Derek.
Take Care
Deke

Both erase and del do "exactly" the same thing and are interchangeable. I can only think the duplication is to cover for some early or different DOS versions. Del appears to be more widely used these days (assuming anyone uses DOS at all LOL).
I think that # in front of a batch line is an alternative to REM (which disables the command) but then it would need a space after it. Without the space it would indeed be a bad command because you have to be very precise in DOS.
The size of the win386.swp file relates exactly to the amount of swap file that is in use. Either windows has decided to reserve that amount or a minimum has been set in the system.ini file.
You can peep into system.ini by typing it in the Run box. If there is such a line it would be under the [386Enh] heading and read:
MinPagingFileSize=81920
(which is 80M in KB)
DerekW

.... brain slowing. As win386.swp was presumably in c:\windows then windows is managing it, so there won't be a line in system.ini
DerekW

Is there actually a reason to delete the swapfile, or is this "just because"?
You might consider taking a look at Windows 98 & WinME Memory Management as well as this piece on swap file management
With 160Mb of RAM, you might be better served by dropping that whole erase/delete command and just 'tweak' the swap file management to zero (or near to it) by the
ConservativeSwapfileUsage=1
.. method in System.ini
I'm not one of those who think Bill Gates is the devil. I simply suspect that if Microsoft ever met up with the devil, it wouldn't need an interpreter.

Deke will no doubt elaborate but I got the impression he felt it could contain something undersireable (#9).
I do know some folk believe it should be deleted at times because it can get corrupted. I suppose the new one ends up contiguous so I perhaps that has some minor advantage. Can't say I've every experienced any problem with it.
DerekW

Hi guys,
AFAIK, the only substitute for REM is a colon.
I always use :: so I can readily distinguish the comments from the labels. And they're easy to strip.
If you want to delete the swap file only after a CC run, have the BAT leave a marker:
::== cc.bat
@echo off > c:\marker.cc
::====
Then in autoexec:if exist marker.cc del win386.swp
if exist marker.cc del marker.ccAnd yeah, I think the customary reasons for nixing the swap file are to lose any errors and to have a fresh, contiguous one.
=====================================
If at first you don't succeed, you're about average.M2

Hi,One reason to delete the swap file is to get a better Defrag as the swap file does not get moved by Defrag. Same thing can be accomplished by turning off the Swap File, defraging and then turning it back on.
Jim

M2
I copied the .bat info into the .bat file directly under the other info I had entered.
I also copied the autoexec info as is except I had to add the C:\Windows to it.
Should I have left some of that info for the .bat file off as a regular reboot is erasing my .swp file. This probably doesn't hurt anything but I would like it to delete only when running CCleaner.
Excuse my total ignorance about this.
Take Care
Deke

After thinking about this situation here is my understanding:
When I run CCleaner it leaves a marker that when the reboot starts the autoexec.bat sees this marker and carries out the commands there which includes the erasing of the .swp file and the erasing of the marker left by CCleaner.
I guess my problem lies with what I put in autoexec as a regular reboot erases the swp file even though CCleaner wasn't ran and didn't leave a marker.
Take Care
Deke

Post your autoexec.
=====================================
If at first you don't succeed, you're about average.M2

JimPIM
Yes, that's what we all meant by contiguous.Mechanix2Go
I use :: too. In DOS Box I see they use # (space) so maybe it also works as REM in a normal batch file. I'm not sure why Deke put it in tho.Deke
Yes as given in my #8 "It would then delete it on every boot-up". It wouldn't matter if it did but see new advice given in #14.DerekW

M2
I have never been able to post an image here. Do you need to post it somewhere and then use the url for it?
Take Care
Deke

I finally got the info down where I could put it here. Just copied it instead.
I only have the last two activated.
del c:\windows\win386.swp
erase c:\windows\win386.swp
if exist marker.cc del c:\windows\win386.swp
if exist marker.cc del marker.ccI am use to TSG's image posting.
Take Care
Deke

Easiest way is to open up autoexec.bat in NotePad then Copy/Paste the text onto this page.
There is no need for both the "del" version of that line and the "erase" version. As I said earier you can use either (del being more popular). It will try to delete it twice which is a bit pointless.
Can't see where only the last two are activated but perhaps this will become more clear when you post it as per my first line above.
DerekW

I was trying to get it off the System Configuration Utility, didn't even think about the actual autoexec.bat file.
Here it is:
Rem TShoot:
rem TShoot: del c:\windows\win386.swp
Rem TShoot:
rem TShoot: erase c:\windows\win386.swp
Rem TShoot:
if exist marker.cc del c:\windows\win386.swp
Rem TShoot:
if exist marker.cc del marker.ccI only have the first one and the last two ticked in the SCU autoexec.bat tab.
At the rate I am going I am never going to "snatch the pebble out of the masters hand". Old grasshopper is just going to have to try harder.lol
Take Care
Deke

Derek
Is there a way to edit a previous post?
I meant to say I only have the last two ticked.
Take Care
Deke

No edit on here I'm afraid.
I take it you are referring to ticks in msconfig?
Looking at your paste in #23 only the last line appears to be working, this one:if exist marker.cc del marker.cc
Where you see REM it means they are not functional lines - so either they are unticked in msconfig or they have had REM added some other way.
It's getting a bit messy. I'd suggest that you open up autoexec.bat in NotePad, delete all lines, then put in the two autoexec.bat lines given in #14 (although I'm none too familiar with that process personally). They will then appear ticked in msconfig.
You will also need to add the earlier little bit (#14) into your batch file. Note that M2G has assumed that your batch file is named cc.bat so you might need to adjust things accordingly.
Where anything has to run in true DOS (such as autoexec.bat) keep any "path/directory/file names" within it down to 8 characters max - which includes the name of your batch file.
DerekW

If you have sufficient RAM, setting 'conservative swapfile useage' may reduce your swap to zero, depending on how you use the machine (as per those articles)
... meanwhile, methodically erasing it merely adds to the overhead (but it's your time to waste)
con·tig·u·ous Jim - sound it out
See also su·per·flu·ous
I'm not one of those who think Bill Gates is the devil. I simply suspect that if Microsoft ever met up with the devil, it wouldn't need an interpreter.

Derek
I am seeing the rem on only the first two in my post. That is the rem before the two lines M2 gave me. The are ticked in Misconfig
Take Care
Deke

I'm now confused. You are only seeing the REM on the first two but I can see 6 REM's in post #23.
Confucius he say:
Where abouts are you not seeing the other four?
DerekW

I thought only the rem befor the actual line counted as the following not the Rem Tshoot which is before all of them whether they are ticked in msconfig or not.
Take Care
Deke

The last two with the Rem TShoot before them work when I see the dos window during reboot. There is definitly a pause when the win386.swp is being deleted.
Take Care
Deke

I found this on a link:
When you disable an entry in Config.sys or Autoexec.bat, rem Tshoot: is added above and before the particular line.
I can't see how this is possible as the dos window show a stop for 10 seconds or so after del win380.swp line.
I guess I can live with a delete of the swp file on each reboot.
Thanks guys for the patience and all the help on this.
Take Care
Deke

Usually all you see in Autoexec.bat as far as REM's are concerned is the ones that start with the lower case r, so you seem to have quite a collection.
Whatever delay you might see it is about certain that any line with a rem in front of it (either case) is doing nothing at all. This sends me back to my suggestions in the last three paras of my #25.
Possibly the best way to see if win386.swp is "really" being replaced is to compare notes on it's time stamp. Try some boots with autoexec.bat renamed to autoexec.xxx to disable it. Then rename it back to .bat and see if the time stamp now changes. Currenly I can't see how any of your del or erase commands are doing anything.
DerekW

Ooops, just spotted your #31. Yes without doubt the Tshoot part is added when you untick using msconfig. I have one Tshoot in mine when I untick the boot virus scan. It's just a reminder from MS (troubleshoot).
When you disable manually from the file yourself you just add REM.
DerekW

I am setting here and bored waiting on the Super Bowl and got to thinking about post #14.
@echo off
start /w "c:\program files\ccleaner\ccleaner.exe" /Auto
start c:\windows\rundll32.exe shell32,SHExitWindowsEx 2
::== cc.bat
@echo off > c:\marker.cc
::====Would the ::s if used as they are in the .bat file stop the marker from being left since they are the same as Rem? And should they be used?
Take Care
Deke

Re #34. These came from M2G who has a deeper knowledge of batching than I, and he's usually on the ball. Maybe he'll pop back. The fact that there is no space after the :: could make all the difference.
Did you try it?
Generally I don't regard win386.swp as a big problem. You could always just type del c:\windows\win386.swp to delete it from time to time via DOS, or you could delete it on every boot with autoexec.bat as previously discussed.
DerekW

Obviously, I should have been more clear.
A colon as the first char in a line is seen as a label. This is a label
:sub1
this is NOT a valid label
::sub2
What I intended with this
::== cc.bat
@echo off > c:\marker.cc
::====was the first and last lines are 'cut lines' which you can leave in or leave out. They just set off the BAT from the rest of the post.
You need this
@echo off > c:\marker.cc
as the FIRST line in your BAT. With it at the end it will never be run because it reboots before it gets there.
So here's your finished BAT
::============ my.bat
@echo off > c:\marker.cc
start /w "c:\program files\ccleaner\ccleaner.exe" /Auto
start c:\windows\rundll32.exe shell32,SHExitWindowsEx 2
::== DONEDerek, I'm pretty sure this handling of colons is consistent at least back to DOS 3.10
=====================================
If at first you don't succeed, you're about average.M2

Thanks for getting back to me with that info.
Here is what I have in my bat now:
@echo off > c:\marker.cc
start /w "c:\program files\ccleaner\ccleaner.exe" /Auto
start c:\windows\rundll32.exe shell32,SHExitWindowsEx 2I left the "cut" lines out.
Take Care
Deke

Hopefully that will do ya.
=====================================
If at first you don't succeed, you're about average.M2

M2
I normally use :: (space) as a label. I assume from what you've said that my second : and the space become part of the label. Something I must have gotten from somewhere or other and obviously never checked up on as it always worked. Thx for info.
DerekW

Hi Derek,
Looks like I shot myself in the foot.
This needs much mire study.
=====================================
If at first you don't succeed, you're about average.M2

I hope this isn't to old of a thread.
My .bat file is working great but when CCleaner cleans out sometimes the Recycle bin it shows back up as a folder and has some files that will not delete.
I can delete it from DOS but would like to add the--Deletree C:\Recycle-- to my Autoexec.bat file. I added it like the above but then I don't know how to add the confirmation(N or Y), that will complete the task0 it ask for in the above .bat entry.
Take Care
Deke

I tried the following and it ask for a confirmation on each item in the Recycle Bin:
deltree c:\Recycled\*.* /y
Take Care
Deke

I don't think deltree is a good idea. If you delete a 'system' folder windows may lose it's way.
Just
del /q recycled
=====================================
If at first you don't succeed, you're about average.M2

I tried your suggestion and got the following:
Invalid -/Q Swithch
The recycle bin still had some stuff in it after rebooting.
Take Care
Deke

Deltree by definition deletes all folders, sub-folders and files (so you don't need *.*). Your command format was a tad adrift though.
Just write:
deltree /y c:\recycled
This will remove the bin (plus all of its contents) and it will rebuild automatically on restart - quite safe.
Note, I have never tried this in autoexec.bat but I can't see why it shouldn't work and be quite safe to try.
Any problems, shout back. I'm on XP now but if my memory fails me I can refer back to notes on my old W98SE if need be.
No problem with keeping this thread running. They last way over a month these days before they become read-only.
DerekW

Thanks Derek that did the trick.
I don't know why the CCleaner was causing the wierd happenings after delete the contents of the RB.
I guess I am going to have to go ahead a give up on this old Ace and W98se. I was at Bestbuy today and looked at some 15.4 and 17 inch laptops and they looked huge compared to my 12 inch or so. I guess I might as well go with vista as the only xp I have done is on my buddies pc.
M2Go-Thanks for your input also.
Take Care
Deke

One other thing I should remember and due to old age I can't.
When I added something to my autoexec.bat and then deleted it there is one of the C:\s left. I now have four of them that show up on the bootup screen.
Take Care
Deke

Age - no chickens have responded to this post LOL....
If you have several C:\'s in your autoexec.bat then probably all or most are uneccessary. Best to copy/paste the contents on here so that we can have a quick look.
As often as not they do no more than introduce spurious line feeds when seen running during start up.
Tread a little carefully on LCD monitor sizes. The native resolution is always the best but this can make things look "really small" on the larger screens.
There is another issue too. Most screens are 4:3 ratio (such as 15 inch, 1024x768). When you go for 17 inch (1280x1024) they are 5:4 - something of an odd man out.
On both W9x and XP you can cook the books in Display Properties to stop everyone looking narrow on 5:4 but there are other issues when you do things like viewing webpages.
What I'm trying to say is consider going no further than 15" because if things are too small you can always accept a slightly lower quality image without any change in proportion.
I'm running a 17" LCD on XP now but it took a lot of work to get to "nearly" like it (although I'm a funny bloke who objects to things looking narrow).
I've no idea about Vista so I suppose it is just possible that problem has been fixed in that OS but it is well worth checking first.
You are sure to be OK on 15" 1024x768, or any combination where the long side divided by the short side equals 1.33333
DerekW

I guess I didn't say the part about the C:\>s right. They don't show up in the actual autoexec.bat file when I open it.
They only show up on the bootup screen right after Deleting C:\Recycled.
C:\>
C:\>
C:\>
C:\>I had about decided the 15.4 would big enough for my needs.
Take Care
Deke

Finally found the cure:
You probably have an
extra CR LF (carriage return, line-feed), at the end of your autoexec.bat
file. This won't show up in the
editor window. It also doesn't hurt anything. If you want to get rid of it
though, try going into "sysedit" from the
START>RUN menu. Just place your cursor at the end of the last line and hit
"Delete" several times. That
should clear it up.Found it at this link:
http://groups.google.com/group/alt....
Take Care
Deke

Yep. It's best to get into the habit of having no line feed at all at the end of a batch file (unless you want a C:\ to show on the screen when it is an Autoexec.bat file).
If you ever get into .reg files then they are different. You always need either one or two line feeds (but no more).
DerekW

I guess a little knowledge is a dangerous thing.
What I would like to do with my cc.bat file is make it leave a marker to delete the Recycle bin. That way I will not be deleting the RB on every bootup.
Here is what I have in my autoexec.bat and my CC.bat files:
if exist marker.cc del c:\windows\win386.swp
if exist marker.cc del marker.cc
deltree /y c:\recycled@echo off > c:\marker.cc
start /w "c:\program files\ccleaner\ccleaner.exe" /Auto
start c:\windows\rundll32.exe shell32,SHExitWindowsEx 2I promise you I will cease and desist after this one.
Take Care
Deke

if exist marker.cc del c:\windows\win386.swp
if exist marker.cc deltree /y c:\recycled
if exist marker.cc del marker.cc
=====================================
If at first you don't succeed, you're about average.M2

M2Go
I hated to bug you guys to death but I am somewhat of a perfectionist with very little computer savy.
The info you gave me works to perfection. Now I don't delete my recycle bin on every boot, only when I run CC.
Thanks again to you and also Derek. You guys Rock.
Take Care
Deke

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |