Solved

Disk Cleanup Schedule Task

Posted on 2009-04-06
7
452 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
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

I hope you'll find this tutorial useful and interesting. So let's try to extend Tcl with a new package.  For anyone more deeply interested please check out the book "Practical Programming in Tcl and Tk". It's really one of the best written books abo…
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…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

705 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

18 Experts available now in Live!

Get 1:1 Help Now