Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 478
  • Last Modified:

Disk Cleanup Schedule Task

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
techguyjohn
Asked:
techguyjohn
  • 4
  • 3
1 Solution
 
sirbountyCommented:
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
 
techguyjohnAuthor Commented:
No dice, after running the bat file with that command in it, it dosent add a new task in the task scheduler.
0
 
sirbountyCommented:
my mistake - it shoud've been %systemroot%\system32\cleanmgr...
0
[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

 
sirbountyCommented:
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
 
techguyjohnAuthor Commented:
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
 
techguyjohnAuthor Commented:
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
 
sirbountyCommented:
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

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now