none
Help with Logoff Script to delete user profile temp files

    Question

  • Hi folks.  I want to add a logoff script to all of my users that will delete everything in the following folders:

    C:\Documents and Settings\LocalService\Local Settings\Temp
    C:\Documents and Settings\LocalService\Local Settings\Temporary Internet Files

    I have tried the following script in a batch file:

    del *.* /s /q C:\Documents and Settings\%username%\Local Settings\Temp
    del *.* /s /q C:\Documents and Settings\%username%\Local Settings\Temporary Internet Files

    This however ends in the following:

    C:\Documents and Settings\Administrator\Desktop>del *.* /s /q C:\Documents and S
    ettings\Administrator\Local Settings\Temp
    The system cannot find the path specified.

    C:\Documents and Settings\Administrator\Desktop>del *.* /s /q C:\Documents and S
    ettings\Administrator\Local Settings\Temporary Internet Files
    The system cannot find the path specified.

    I'm guessing this is because these are hidden system directories?  I'm not sure how to get around this though.  Help would be greatly appreciated.  Thanks.

    Wednesday, April 07, 2010 8:00 PM

All replies

  • Okay what we go do is, a xp systemrecovery all your data remains on your pc.
    Because the ''program'' is of Windows XP.

    Okay pull all extern devices out your pc. Okay There we go !

    1. Shutdown your Anti-virus scanner, and all programs.

    2. Go to start > All Programs > Desk accessories > Systemworkset.

    3. Select ''Systemrecovery''.

    4. Select ' a existing recover' ( Your pc make this automatic, at the install of a program )

    5. klick on, next > Select a date when you pc good worked !

    6. klick on, next > Your pc is now restore.

    many success !

    Dynam

    You're a real rocket scientist.
    Saturday, April 10, 2010 12:38 PM
  • Try this. Copy it into notepad and save it as DelTemp.bat

     

    @ECHO OFF 

    SET SRC1=C:\Documents and Settings

    SET SRC2=Local Settings\Temporary Internet Files\Content.IE5

    SET SRC3=Local Settings\History

    SET SRC4=Local Settings\Temp

    SET SRC5=Recent


    echo About to delete files from Internet Explorer "Temporary Internet files"

    FOR /D %%X IN ("%SRC1%\*") DO FOR /D %%Y IN ("%%X\%SRC2%\*.*") DO RMDIR /S /Q "%%Y"


    echo About to delete files from Internet Explorer "History"

    FOR /D %%X IN ("%SRC1%\*") DO FOR /D %%Y IN ("%%X\%SRC3%\*.*") DO RMDIR /S /Q "%%Y"

    FOR /D %%X IN ("%SRC1%\*") DO FOR  %%Y IN ("%%X\%SRC3%\*.*") DO DEL /F /S /Q "%%Y"


    echo About to delete files from "Local settings\temp"

    FOR /D %%X IN ("%SRC1%\*") DO FOR /D %%Y IN ("%%X\%SRC4%\*.*") DO RMDIR  /S /Q "%%Y"

    FOR /D %%X IN ("%SRC1%\*") DO FOR  %%Y IN ("%%X\%SRC4%\*.*") DO DEL /F /S /Q "%%Y"


    echo About to delete files from "Recent" i.e. what appears in Start/Documents/My Documents

    FOR /D %%X IN ("%SRC1%\*") DO FOR  %%Y IN ("%%X\%SRC5%\*.lnk") DO DEL /F /S /Q "%%Y"


    echo About to delete files from "Windows\Temp"

    cd /d %SystemRoot%\temp

    del /F /Q *.*


    @echo Y|RD /S ""


    exit

    Friday, April 23, 2010 11:50 PM
  • Hi,

    Your Script look like working through progress but the thing is am getting error as "Access is denied" for all the files.

    Will you please explain me how to bypass that in a script. 

    Friday, May 09, 2014 12:12 PM