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...
Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

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

How Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

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 while and for loops in Python.  while loops are used for testing while, or until, a condition is met: The structure of a while loop is as follows:     while <condition>:         do something         repeate: The break statement m…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

734 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