Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hide Disk Cleanup as Scheduled Task

Status
Not open for further replies.

dhscott

IS-IT--Management
Jan 7, 2004
22
0
0
US
I'm trying to add Disk Cleanup as a scheduled task for all users on our network. I can create the scheduled task ok, and I get it to run ok using cleanmgr.exe /sagerun:n , but is there a way to run it in the background, hidden from the users? Or at least have it run minimized?

Also, when you run cleanmgr.exe /sageset:n (to set the cleanup setting), it saves those settings in the registry, any idea where?

Any suggestions would be appreciated.
Thanks
 
315246 - How to Automate the Disk Cleanup Tool in Windows XP


This key contains the options checked by Disk Cleanup in manual running.

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches

If you have used sageset and sagerun switches does searching the registry for those two terms turn up anything?

I am not sure if you can do what you want to in the first part of your question, because you are deleting users files and they should have a say in that. Perhaps someone else can help you with that question.
 
linney- thanks for the registry location, that solves one issue :)

I still need to find out if it's possible to run an exe hidden or at least minimized. I would think there has to be some kind of DOS command to minimize.

Thanks for you help
 
You can use WMI to start the process remotely. It will then run in a different user session and not be interactive with your users.

here is a sample script that does what I am talking about:

strComputer = "webserver"
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2:Win32_Process")

Error = objWMIService.Create("notepad.exe", null, null, intProcessID)
If Error = 0 Then
Wscript.Echo "Notepad was started with a process ID of " _
& intProcessID & "."
Else
Wscript.Echo "Notepad could not be started due to error " & _
Error & "."
End If
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top