Disk Cleanup Schedule Task

Posted on 2009-04-06
Last Modified: 2012-05-06

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.

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

Open in new window

Question by:techguyjohn
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
LVL 67

Expert Comment

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


Author Comment

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

Expert Comment

ID: 24080486
my mistake - it shoud've been %systemroot%\system32\cleanmgr...
Tutorials alone can't teach real engineering

So we built better training tools.

-Hands-on Labs
-Instructor Mentoring
-Scenario-Based Tests
-Dedicated Cloud Servers

All at your fingertips. What are you waiting for?

LVL 67

Accepted Solution

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

Author Comment

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.

Author Comment

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.
LVL 67

Expert Comment

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. 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...

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction: Recently, I got a requirement to zip all files individually with batch file script in Windows OS. I don't know much about scripting, but I searched Google and found a lot of examples and websites to complete my task. Finally, I was ab…
This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
Learn the basics of if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

617 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