Re: Scripting for cleanup utilities run by Task Scheduler on logge
From: dave (anonymousguy_at_somewhere.com)
Date: 12/10/04
- Next message: badgolferman: "how to disable logon message"
- Previous message: BruceT: "Re: File sharing on wireless network"
- In reply to: Pegasus \(MVP\): "Re: Scripting for cleanup utilities run by Task Scheduler on logge"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 10 Dec 2004 05:59:03 -0800
The "disk cleanup" utility is a native windows tool that cleans temp files.
It is cleanmgr.exe. There is a sageset:n argument that sets the registry
http://www.iamnotageek.com/a/64-p1.php. I set that, and exported those to a
.reg file I named cleanmgr.reg. My batch file imports that into the registry.
Then the batch file runs the cleanmgr command that uses those settings from
the registry.
"Pegasus (MVP)" wrote:
> You can delete any file while the user is logged off by scheduling
> a batch file to run in the middle of the night. Its activities would be
> restricted to your PC and would not extend to other things, as
> suggested in the item between quotes in your latest reply . . .
>
>
> "dave" <anonymousguy@somewhere.com> wrote in message
> news:BB4A5001-8607-4A36-88F9-6EBCCA2AF7E1@microsoft.com...
> > Thank you for the reply!
> > OK, I will consider your warnings on defrag, I've seen debates on its
> > usefullness or not but Im certain the powers that be here at work will
> decide
> > that I will need to defrag our machines!
> > The other part of my script is intended to delete temp files using the
> "Disk
> > Cleanup" wizard ("cleanmgr.exe"). I dont do any registry cleaning in this
> > script. The regedit command takes the cleanmgr.reg file and imports it
> into
> > the registry in order to configure the "*** cleanup" wizard parameters.
> Is
> > there a better way to have that run properly when the machine is logged
> off?
> > I'll modify the scripts as you shown to generate the standard output to
> look
> > back at errors after the scripts run.
> >
> > "Pegasus (MVP)" wrote:
> >
> > >
> > > "dave" <dave@discussions.microsoft.com> wrote in message
> > > news:CBBDEAC0-38CD-42F4-B380-3C559FBA788C@microsoft.com...
> > > > I would like to be able to run the disk cleanup utility, defrag, and
> > > restart
> > > > our computers overnight using free tools, while the computer is logged
> > > off. I
> > > > am having trouble getting this to run properly (called from a
> scheduled
> > > task,
> > > > with a domain admin account for authentication) on logged off Windows
> 2000
> > > > computers, I have not fully tested this on XP. It seems to run
> correctly
> > > when
> > > > it is logged on, but they do not run when the machine is logged off.
> Has
> > > > anyone else gotten this to work? How would I do this? Thank you in
> advance
> > > > for your help!
> > > >
> > > >
> > > > 1] I wrote two scripts, one for windows 2000, and another for windows
> xp:
> > > > ---------{snip}------------------
> > > > rem "MaintXP.bat"
> > > > rem Windows XP script
> > > > regedit /s c:\scripts\cleanmgr.reg
> > > > cleanmgr.exe /sagerun:1
> > > > defrag C: -f
> > > > C:\scripts\shutdown.exe /R /T:2
> > > > ---------{/snip}-----------------
> > > >
> > > > ---------{snip}------------------
> > > > rem "Maint2k.bat"
> > > > rem Windows 2000 script
> > > > regedit /s c:\scripts\cleanmgr.reg
> > > > cleanmgr.exe /sagerun:1
> > > > C:\scripts\AutoDeFrag.exe
> > > > C:\scripts\shutdown.exe /R /T:2
> > > > ---------{/snip}-----------------
> > > >
> > > > 2] I downloaded two files:
> > > > 1) Shutdown.exe: From the Windows 2000 Resource Kit, can be downloaded
> > > here
> > > > http://www.petri.co.il/download_free_reskit_tools.htm
> > > > 2) Autodefrag.exe:
> > > > http://www.morphasys.com/autodefrag/
> > > >
> > > > 3] I created a cleanmgr.reg file that will configure the registry for
> the
> > > > Disk Cleanup Wizard:
> > >
> > ---------{snip}-----------------------------------------------------------
> > > -------------
> > > > Windows Registry Editor Version 5.00
> > > >
> > > >
> > >
> [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Volum
> > > eCaches]
> > > >
> > > >
> > >
> [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Volum
> > > eCaches\Active Setup Temp Folders]
> > > > "StateFlags0001"=dword:00000002
> > > >
> > > >
> > >
> [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Volum
> > > eCaches\Content Indexer Cleaner]
> > > > "StateFlags0001"=dword:00000002
> > > >
> > > >
> > >
> [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Volum
> > > eCaches\Downloaded Program Files]
> > > > "StateFlags0001"=dword:00000002
> > > >
> > > >
> > >
> [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Volum
> > > eCaches\Internet Cache Files]
> > > > "StateFlags0001"=dword:00000002
> > > >
> > > >
> > >
> [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Volum
> > > eCaches\Offline Files]
> > > > "StateFlags0001"=dword:00000002
> > > >
> > > >
> > >
> [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Volum
> > > eCaches\Offline Pages Files]
> > > > "StateFlags0001"=dword:00000002
> > > >
> > > >
> > >
> [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Volum
> > > eCaches\Old ChkDsk Files]
> > > > "StateFlags0001"=dword:00000002
> > > >
> > > >
> > >
> [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Volum
> > > eCaches\Recycle Bin]
> > > > "StateFlags0001"=dword:00000002
> > > >
> > > >
> > >
> [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Volum
> > > eCaches\Temporary Files]
> > > > "StateFlags0001"=dword:00000002
> > > >
> > > >
> > >
> [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Volum
> > > eCaches\Temporary Offline Files]
> > > > "StateFlags0001"=dword:00000002
> > >
> > ------------{/snip}-------------------------------------------------------
> > > ------------------
> > > >
> > > >
> > > > 4] I drop all of these files into C:\scripts directory, and set a
> > > scheduled
> > > > task to run the respective batch file (depending on what OS it is) at
> > > night
> > > > when the computer is logged off.
> > > >
> > >
> > > I think your script is a recipe for disaster. Defragging is much
> > > like open heart surgery and should be performed sparingly. In
> > > most cases you would not be able to tell the difference without
> > > a stop watch - if at all. If you have a power failure during a
> > > defrag operation then you might lose your whole disk.
> > >
> > > Cleaning the registry is even worse: It is in most cases
> > > unnecessary, and it can completely cripple your PC.
> > >
> > > Doing these things may give you a warm feeling inside but it
> > > won't to make your PC run better. Have you ever measured
> > > the effect of these actions in a tightly controlled test?
> > >
> > > If you wish to persist then you need to be more specific about
> > > the steps that fail in your script. Add some basic diagnostics
> > > like so:
> > >
> > > 1 @echo off
> > > 2 echo %date% %time% Start of cleanup > c:\test.log
> > > 3 echo Username=%UserName%, Path=%path%>>c:\test.log
> > > 4 regedit /s c:\scripts\cleanmgr.reg 1>>c:\test.log 2>>c:\test.err
> > > 5 echo %date% %time% End of cleanup >> c:\test.log
> > >
> > >
> > >
>
>
>
- Next message: badgolferman: "how to disable logon message"
- Previous message: BruceT: "Re: File sharing on wireless network"
- In reply to: Pegasus \(MVP\): "Re: Scripting for cleanup utilities run by Task Scheduler on logge"
- Messages sorted by: [ date ] [ thread ]