Clean Temp Files

Comments

8 comments

  • Steve Elgan

    Very cool idea. I was looking for something like this. Any way for it to loop through all user profiles on the drive instead of just the currently logged in user?

    0
    Comment actions Permalink
  • Steve Elgan

    Found out how. Resubmitting back. Thanks!

     

    <?xml version="1.0" encoding="utf-8"?>
    <AdminArsenal.Export Code="PDQDeploy" Name="PDQ Deploy" Version="11.2.0.0" MinimumVersion="3.1">
    <Package>
    <PackageDefinition name="Definition">
    <CopyMode>Default</CopyMode>
    <InventoryScanProfileId value="null" />
    <RunAs value="null" />
    <ScanAfterDeployment value="null" />
    <Steps type="list">
    <CommandStep>
    <Command>cd /D C:\users
    for /D %%a in (*.*) do DEL /F /S /Q "%%a\Local Settings\Temp\*.*"
    for /D %%a in (*.*) do FOR /D %%b IN ("%%a\Local Settings\Temp\*.*") DO RMDIR /S /Q "%%b"
    for /D %%a in (*.*) do DEL /F /S /Q "%%a\Local Settings\Temporary Internet Files\*.*"
    for /D %%a in (*.*) do FOR /D %%b IN ("%%a\Local Settings\Temporary Internet Files\*.*") DO RMDIR /S /Q "%%b"</Command>
    <Files></Files>
    <SuccessCodes>0,1,255</SuccessCodes>
    <RunAs value="null" />
    <Conditions type="list">
    <PackageStepCondition>
    <Architecture>Both</Architecture>
    <Version>All</Version>
    <TypeName>OperatingSystem</TypeName>
    </PackageStepCondition>
    <PackageStepCondition>
    <IsUserLoggedOn>AlwaysRun</IsUserLoggedOn>
    <TypeName>LoggedOnUser</TypeName>
    </PackageStepCondition>
    </Conditions>
    <ErrorMode>StopDeploymentFail</ErrorMode>
    <IsEnabled value="true" />
    <Title>Clean User Appdata Temp Files-Folders</Title>
    <TypeName>Command</TypeName>
    </CommandStep>
    <CommandStep>
    <Command>del /q /s %systemroot%\temp\*
    for /d %%x in (%systemroot%\temp\*) do @rd /s /q "%%x"</Command>
    <Files></Files>
    <SuccessCodes>0,1,255</SuccessCodes>
    <RunAs value="null" />
    <Conditions type="list">
    <PackageStepCondition>
    <Architecture>Both</Architecture>
    <Version>All</Version>
    <TypeName>OperatingSystem</TypeName>
    </PackageStepCondition>
    <PackageStepCondition>
    <IsUserLoggedOn>AlwaysRun</IsUserLoggedOn>
    <TypeName>LoggedOnUser</TypeName>
    </PackageStepCondition>
    </Conditions>
    <ErrorMode>StopDeploymentFail</ErrorMode>
    <IsEnabled value="true" />
    <Title>Clean Windows Temp</Title>
    <TypeName>Command</TypeName>
    </CommandStep>
    <CommandStep>
    <Command>del /q /s %systemdrive%\temp\*
    for /d %%x in (%systemdrive%\temp\*) do @rd /s /q "%%x"</Command>
    <Files></Files>
    <SuccessCodes>0,1,255</SuccessCodes>
    <RunAs value="null" />
    <Conditions type="list">
    <PackageStepCondition>
    <Architecture>Both</Architecture>
    <Version>All</Version>
    <TypeName>OperatingSystem</TypeName>
    </PackageStepCondition>
    <PackageStepCondition>
    <IsUserLoggedOn>AlwaysRun</IsUserLoggedOn>
    <TypeName>LoggedOnUser</TypeName>
    </PackageStepCondition>
    </Conditions>
    <ErrorMode>StopDeploymentFail</ErrorMode>
    <IsEnabled value="true" />
    <Title>Clean C: Temp</Title>
    <TypeName>Command</TypeName>
    </CommandStep>
    <CommandStep>
    <Command>del /q /s %systemroot%\Logs\CBS\*
    for /d %%x in (%systemroot%\Logs\CBS\*) do @rd /s /q "%%x"</Command>
    <Files></Files>
    <SuccessCodes>0,1,255</SuccessCodes>
    <RunAs value="null" />
    <Conditions type="list">
    <PackageStepCondition>
    <Architecture>Both</Architecture>
    <Version>All</Version>
    <TypeName>OperatingSystem</TypeName>
    </PackageStepCondition>
    <PackageStepCondition>
    <IsUserLoggedOn>AlwaysRun</IsUserLoggedOn>
    <TypeName>LoggedOnUser</TypeName>
    </PackageStepCondition>
    </Conditions>
    <ErrorMode>StopDeploymentFail</ErrorMode>
    <IsEnabled value="true" />
    <Title>Clean Windows CBS Logs</Title>
    <TypeName>Command</TypeName>
    </CommandStep>
    </Steps>
    <Timeout value="60" />
    <UseCustomTimeout value="false" />
    </PackageDefinition>
    <Description>credit to:
    https://support.adminarsenal.com/hc/en-us/community/posts/213917368-Clean-Temp-Files
    https://community.spiceworks.com/scripts/show/3123-remotely-delete-temp-internet-files-temp-files-from-all-local-profiles-windows-2008-win7</Description>
    <FolderId value="null" />
    <Name>Clean Temp Files</Name>
    <Path>Clean Temp Files</Path>
    <Version></Version>
    <PackageDisplaySettings name="DisplaySettings">
    <DisplayType>Normal</DisplayType>
    <IconKey></IconKey>
    <SortOrder value="8" />
    </PackageDisplaySettings>
    </Package>
    </AdminArsenal.Export>

    1
    Comment actions Permalink
  • Kevin Myers

    Very cool guys!! I was looking for something like this since we seem to have a lot of PC's with 50 to 60 gigs of Temporary Files. This worked great!! Thanks for the post fellas.

    0
    Comment actions Permalink
  • Kevin Prowell

    If I may, being new with this how would I package this to be used with PDQ Deploy?

     

    UPDATE:

    Disregard.  I wasn't thinking.  I saved it as an xml file and then imported it.  Thanks! 

    0
    Comment actions Permalink
  • Stephen Valdinger

    Copy all of the text from above and save it as <something relevant>.xml

     

    Then Go into PDQ Deploy and File > Import. Browse to your XML file and it will import it as a package for you to use. 

    0
    Comment actions Permalink
  • Kevin Prowell

    Yes, thanks!.  Slow morning.....not enough coffee yet.  :)

    0
    Comment actions Permalink
  • Matthew Reyes

    Very cool!  Deployed to a few test systems and it seems to work well with Windows 7.  I'm going to try this on Win10 here after a bit.

     

    Thanks!!!

    0
    Comment actions Permalink

Please sign in to leave a comment.