Kaseya Community

Disk Cleanup Script?

  • I find disk cleanup to be extremely effective a speeding up a slow PC, after you remove the spyware... Of course most of the spyware resides in users temp folders. C:\Documents and Settings\%user%\Local Settings\Temp, and \Temporary Internet Files.

    I also would like it to clean ALL user's temp folders. Usually it only cleans C:\Temp and the logged in user's Temp folders.

    I have been using either Norton System Works Disk Cleanup or System Mechanic 5 disk maintenence wizard to clean temp files.


    Legacy Forum Name: Disk Cleanup Script?,
    Legacy Posted By Username: rx7kevin
  • I am working on Cleanmgr.exe script. Here is what I have so far:

    The command(s): cleanmgr.exe /sagerun:n see MSKB here:

    http://support.microsoft.com/kb/q253597/

    n = any number you enter. This becomes a profile number and the Cleanmgr properties starts. You then choose which items to clean. Temp Files, Temporary Internet Files, Etc... When you click OK it saves this setting inthe regisry:

    HKLM\Software\Microsoft\Windows\CurrentVersion\Explorer\VolumeCache

    In this key you will find a list of all options for Cleanmgr: Temp Files, Temporary Internet Files, Etc... Inside each folder will be a key:

    StateFlag0023 REG_WORD 0x00000002 (2)

    This key was created by cleanmgr.exe /sageset:23 I randomly chose the number, it can be any number between 1 and 65535. The key will only show in the choosen options.

    My main issue is how to copy these settings from the registry and put them on another computer with kaseya. If that can be done, then you can simply use a script to start cleanmgr... cleanmgr /sagerun:23 this will run with the chosen options on all agents.


    Legacy Forum Name: System Administration Scripts,
    Legacy Posted By Username: rx7kevin
  • Within the Kaseya scripting you can create registry entries.

    Legacy Forum Name: System Administration Scripts,
    Legacy Posted By Username: jimalves
  • Disk Cleanup-Temp Files Install.txt
    Here is my /sageset:91 script. It cleans only'Temp files'.

    ***Problem with cleanmgr.exe /sagerun:91

    WhenI run the/sagerun:91 script, cleanmgr.exe starts and removes files. When I checked the temp folders: #agentDrv#\Documents& Settings\%user%\local settings\temp and #agent#\temp, nothing was removed. If I manually run /sageset:91 the /sagerun:91 it cleans...


    Legacy Forum Name: System Administration Scripts,
    Legacy Posted By Username: rx7kevin
  • Which execute option are you using with the execute file command. As User or As System?

    Legacy Forum Name: System Administration Scripts,
    Legacy Posted By Username: jimalves
  • Execute Shell Comand as System

    Legacy Forum Name: System Administration Scripts,
    Legacy Posted By Username: rx7kevin
  • Try executing as the User.

    Legacy Forum Name: System Administration Scripts,
    Legacy Posted By Username: jimalves
  • I tried this as User but no avail. ALL of the 'Temp" folders have the same garbage in them. Temp folder =

    C:\documents & settings\%user%\local settings\temp

    C:\documents & settings\%user%\local settings\temporary internet files

    C:\Temp

    These are just some. The cleanmgr.exe /sageset:n lets you choose which type of folders to clean. But so far, no dice.


    Legacy Forum Name: System Administration Scripts,
    Legacy Posted By Username: rx7kevin
  • I see in your scripts that you are creating registry entries. I also notice that the key end with 0091. Where does that come from. When I run cleanmgr, the reg keys created end in 0001.

    Legacy Forum Name: System Administration Scripts,
    Legacy Posted By Username: jimalves
  • When you run cleanmgr.exe /sageset:n n=any number between 1-65545. This number is arbitrary. When you run this command from rhe run box, disk cleanup will start and give you many more options for cleanup.

    Which ever options you check will create registry entries. Look for StateFlags:0091. For the options you did check the StateFlags:0091 will have a DWORD value of 2, all others will be 1.

    The command cleanmgr.exe /sagerun:n is suppose to clean all of the checked enrties, ie temp folders and files. (Maybe cleanmgr.exe only remove *.tmp file?).

    So, if you run cleanmgr.exe /sagerun:91 it should clean all of the checked entries.

    Maybe I am missing something... Here is where I got most of my info:

    http://support.microsoft.com/kb/q253597/


    Legacy Forum Name: System Administration Scripts,
    Legacy Posted By Username: rx7kevin
  • Created a script. Ran as the User and wait for completion. Worked fine. When you run as System, it does not work.

    Legacy Forum Name: System Administration Scripts,
    Legacy Posted By Username: jimalves
  • I ran it as a user at it did clean up temp files. For some reason I was wanting it to pretty much remove an rogue files in the temp folder, ie: any .exe or known spyware/virus files. That is where they typically start their infestation.

    I am working with a product from www.iolo.com. I have been using their System Mechanic Pro as an all-in-one solution for my clients. But, even at $33 a license I gets expensive to cover all of my clients.

    They have a VAR product, System Mechanic Mobile Toolkit for $220. It can be run from CD and has unlimited licensing. It does not have a scheduling agent because it is only suppose to run from the CD, but that is what Kaseya is for right?

    I am working ona script to write and install to each workstation. It requires that you enter the serial number info when you first run it on a PC.




    Legacy Forum Name: System Administration Scripts,
    Legacy Posted By Username: rx7kevin
  • Can someone post the script?

    Legacy Forum Name: System Administration Scripts,
    Legacy Posted By Username: BCarder
  • What about using http://www.ccleaner.com/. It is a freeware utility that is useful for cleaning up junk. It is very quick and does generate a log. Another good feature is that the application can be modified to clean up additional programs. ... users can add to the already powerful default settings.

    Give the program a try. I'm sure you will find it useful.



    Legacy Forum Name: System Administration Scripts,
    Legacy Posted By Username: mfrancis
  • We are using the perfect answer to this. It is a product called Ace Utilities from Ace Logix Softwarehttp://www.acelogix.com/

    The standard product is excellent but even better was the fact that the developer behind Ace Utilities has modified it several times for us so that it cleans up all temporary file locations, including the OLK folders created by Outlook when you open an attachment.

    As well as file cleanup, Ace Utilities includeshistory cleanup & registry cleanup along with a number of other very useful utilities.

    We run the temp file cleanup, history cleanup & registry cleanup process on a regular basis across all of our managed machines using a Kaseya script that runs Ace Utilities with some command line parameters.

    You should contact Hari Krishnan at Ace Logix hari@acelogix.com


    Legacy Forum Name: System Administration Scripts,
    Legacy Posted By Username: TechOnline