Solved

Is there any way to automate this?

Posted on 2009-07-12
5
258 Views
Last Modified: 2012-05-07
Hi I was wondering if there is anyway to automate this:

%SystemRoot%\System32\Cmd.exe /c Cleanmgr /sageset:65535 & Cleanmgr /sagerun:65535

I put it in tasks but it asks for which file types to clean, is there anyway that cleanmgr will automatically select the last thing and run as stated in the command?

thanks
0
Comment
Question by:emelnik
  • 3
  • 2
5 Comments
 
LVL 10

Expert Comment

by:blohrer
Comment Utility
I think you want to separate this...
You only need to run cleanmgr /sageset:65535 once, this allows you to pick which options you want.
You only need to schedule cleanmgr /sagerun:65535
The reason that you keep seeing the selection screen is because you keep calling it.
Bill
0
 
LVL 10

Expert Comment

by:JonLambert
Comment Utility
When you execute the /sageset command, it adds a 'StateFlag' key in the registry for each of the disk cleanup components for the number/index specified in the command.  It adds a value of 2 for selected, and 0 for unselected.

If you want to automate this proccess, you could import a .REG file first (like the one attached, from a /SageSet:1111), then run your /sagerun command.

e.g. %SystemRoot%\System32\Cmd.exe /c regedit /s c:\windows\temp\Cleanmgr.reg & Cleanmgr /sagerun:1111
Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Active Setup Temp Folders]

"StateFlags1111"=dword:00000000

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Downloaded Program Files]

"StateFlags1111"=dword:00000002

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Internet Cache Files]

"StateFlags1111"=dword:00000002

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Memory Dump Files]

"StateFlags1111"=dword:00000000

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Microsoft_Event_Reporting_2.0_Temp_Files]

"StateFlags1111"=dword:00000002

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Offline Pages Files]

"StateFlags1111"=dword:00000002

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Old ChkDsk Files]

"StateFlags1111"=dword:00000000

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Previous Installations]

"StateFlags1111"=dword:00000000

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Recycle Bin]

"StateFlags1111"=dword:00000000

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Setup Log Files]

"StateFlags1111"=dword:00000000

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\System error memory dump files]

"StateFlags1111"=dword:00000000

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\System error minidump files]

"StateFlags1111"=dword:00000000

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Temporary Files]

"StateFlags1111"=dword:00000000

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Temporary Setup Files]

"StateFlags1111"=dword:00000000

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Thumbnail Cache]

"StateFlags1111"=dword:00000000

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Upgrade Discarded Files]

"StateFlags1111"=dword:00000000

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Windows Error Reporting Archive Files]

"StateFlags1111"=dword:00000000

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Windows Error Reporting Queue Files]

"StateFlags1111"=dword:00000000

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Windows Error Reporting System Archive Files]

"StateFlags1111"=dword:00000000

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Windows Error Reporting System Queue Files]

"StateFlags1111"=dword:00000000

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Windows Upgrade Log Files]

"StateFlags1111"=dword:00000000

Open in new window

0
 
LVL 10

Accepted Solution

by:
blohrer earned 500 total points
Comment Utility
Doing sageset:number creates the registry key based on the choices you make.  There is no reason to import a registry key.  The user is running the /sageset command and /sagerun command on the same command line.
You only need to run /sageset:number once, and choose your settings.
You automate the cleanup using the /sagerun:number command
0
 
LVL 10

Expert Comment

by:JonLambert
Comment Utility
I know .. but even though he doesn't need to run /sageset:number more than once ... it's still a manual proccess for every machine  ... now that's ok when you have 10-20 machines, but not when you've got 20,000 spread accross 600 sites.

0
 
LVL 10

Expert Comment

by:blohrer
Comment Utility
Point taken, but wasnt specified in the question...
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

So who is this article for? If you are like most of the computer users out there, you probably only realize the meaning of 'System maintenance' after something goes wrong. This article is for you if you care about keeping your system working opti…
There are many reasons a PC runs slower than when it was new, ranging from malicious software intended to mess things up to simple general Windows use.  Your PC performance may slowly degrade over time without you noticing but when you buy a PC from…
The Task Scheduler is a powerful tool that is built into Windows. It allows you to schedule tasks (actions) on a recurring basis, such as hourly, daily, weekly, monthly, at log on, at startup, on idle, etc. This video Micro Tutorial is a brief intro…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

743 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

17 Experts available now in Live!

Get 1:1 Help Now