Solved

Disk Cleanup Schedule Task

Posted on 2009-04-06
7
459 Views
Last Modified: 2012-05-06
Hi,

Can anyone let me know if this is the proper command for placing a disk cleanup task in the task folder of a computer.  I have run it and it places it in there but it seems to run along time, thats what I think it may need to be tweaked.  Any help will be much appriciated.

Thanks
schtasks.exe /create /SC WEEKLY /D MON /TN dskclnup /TR "\"C:\windows\system32\cleanmgr.exe\"c: -f" /ST 23:30:00 /SD 02/22/2005 /RU SYSTEM
exit

Open in new window

0
Comment
Question by:techguyjohn
  • 4
  • 3
7 Comments
 
LVL 67

Expert Comment

by:sirbounty
ID: 24080409
No need for the exit, but this should be the corrected version:

schtasks /create /SC WEEKLY /D MON /TN dskclnup /TR "%systemroot%\cleanmgr.exe ""c: -f" /ST 23:30:00 /SD 02/22/2005 /RU SYSTEM

0
 

Author Comment

by:techguyjohn
ID: 24080458
No dice, after running the bat file with that command in it, it dosent add a new task in the task scheduler.
0
 
LVL 67

Expert Comment

by:sirbounty
ID: 24080486
my mistake - it shoud've been %systemroot%\system32\cleanmgr...
0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
LVL 67

Accepted Solution

by:
sirbounty earned 250 total points
ID: 24080502
the path isn't necessary either...try this version:


schtasks /create /SC WEEKLY /D MON /TN dskclnup /TR "cleanmgr.exe c: -f" /ST 23:30:00 /SD 02/22/2005 /RU SYSTEM
0
 

Author Comment

by:techguyjohn
ID: 24081413
It just seems to run a long time and I know there isnt that much to clean becuase I checked the file size to clean before I ran the task.  I will award the points regardless, becuase it did work.
0
 

Author Comment

by:techguyjohn
ID: 24087282
Its still running, I started it at 2/6/09 2:40PM and its still running this morning.  What seems to be the problem?  Ill open a new question.
0
 
LVL 67

Expert Comment

by:sirbounty
ID: 24087454
Probably not a valid command.
I've not automated that command myself, but I believe you have to assign a placeholder with the correct definitions first...then run it using that setup.

http://support.microsoft.com/kb/253597 details this more.

For example, in Scheduled Tasks, you could run the following command after running the cleanmgr /sageset:11 command:
cleanmgr /sagerun:11

This essentially uses the parameters you assigned to job 11 for each subsequently scheduled run...
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Recently I have been answering a lot of questions like this in IT forums that I frequent. The question posed is usually something along the lines of "We have software X installed and need to uninstall it for reason Y" or some other variant of the sa…
If like me you are one who spends a lot of time working and scripting with cmd.exe, sometimes it is handy to be able to quickly view a calendar for a given month and year. This script will quickly do just that!  Save the code posted below to a .bat …
Learn the basics of strings in Python: declaration, operations, indices, and slicing. Strings are declared with quotations; for example: s = "string": Strings are immutable.: Strings may be concatenated or multiplied using the addition and multiplic…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

777 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