Solved

Is there any way to automate this?

Posted on 2009-07-12
5
261 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
ID: 24835986
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
ID: 24845518
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
ID: 24848559
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
ID: 24855116
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
ID: 24855238
Point taken, but wasnt specified in the question...
0

Featured Post

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Service applet starts in Extended Mode by Default, with a taskpad on the left of the services pane. This view mode was introduced in XP. As I find it not very usefull, I like to use the Standard view as default, and without the Console tree. …
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…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

832 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