For maintenance purposes I need a script that will delete the Temp files and
Temporary Internet Files. Due to the nature of a utility we're using to
manage client PCs, this script will run as a scheduled task with admin
credentials, and preferably will clear out these files under all profiles on
the target system. I know there are other approaches (eg, edit the login
script or logoff script), but if someone can get the script below to work (I
found it through searches though the poster could not get it to function),
it would be greatly appreciated. Or potentially suggesting an alternative
script to the one below - whatever works!

SET SRC1=C:\Documents and Settings

SET SRC2=Local Settings\Temporary Internet Files

SET SRC3=Local Settings\Temp

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

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"

Re: Need help on simple "FOR" script by Steve

Steve
Mon Jan 29 03:11:21 CST 2007

Ah, ok, it's late and I didn't even fully see what was wrong with the
original script - portions of it were actually working, though ultimately
the one below (for my needs) will not delete the Temporary Internet Files.

The original post that I'm talking about can be found here -
http://www.ozzu.com/ftopic25583.html

rem @ECHO OFF
SET SRC1=C:\Documents and Settings
SET SRC2=Local Settings\Temporary Internet Files\Content.IE5
SET SRC4=Local Settings\Temp
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 "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"


"Steve" <shart@advantagemicro.net> wrote in message
news:12rrdmta5uj9p77@corp.supernews.com...
> For maintenance purposes I need a script that will delete the Temp files
> and Temporary Internet Files. Due to the nature of a utility we're using
> to manage client PCs, this script will run as a scheduled task with admin
> credentials, and preferably will clear out these files under all profiles
> on the target system. I know there are other approaches (eg, edit the
> login script or logoff script), but if someone can get the script below to
> work (I found it through searches though the poster could not get it to
> function), it would be greatly appreciated. Or potentially suggesting an
> alternative script to the one below - whatever works!
>
> SET SRC1=C:\Documents and Settings
>
> SET SRC2=Local Settings\Temporary Internet Files
>
> SET SRC3=Local Settings\Temp
>
> FOR /D %%X IN ("%SRC1%\*") DO FOR /D %%Y IN ("%%X\%SRC2%\*.*") DO RMDIR /S
> /Q "%%Y"
>
> 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"
>


Re: Need help on simple "FOR" script by Steve

Steve
Mon Jan 29 04:27:34 CST 2007

And, coming full circle, I've figured it out. Just a simple removing of
quotes around the %%Y for the Temporary Internet Files line.

"Steve" <shart@advantagemicro.net> wrote in message
news:12rrehpkf2es2e3@corp.supernews.com...
> Ah, ok, it's late and I didn't even fully see what was wrong with the
> original script - portions of it were actually working, though ultimately
> the one below (for my needs) will not delete the Temporary Internet Files.
>
> The original post that I'm talking about can be found here -
> http://www.ozzu.com/ftopic25583.html
>
> rem @ECHO OFF
> SET SRC1=C:\Documents and Settings
> SET SRC2=Local Settings\Temporary Internet Files\Content.IE5
> SET SRC4=Local Settings\Temp
> 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 "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"
>
>
> "Steve" <shart@advantagemicro.net> wrote in message
> news:12rrdmta5uj9p77@corp.supernews.com...
>> For maintenance purposes I need a script that will delete the Temp files
>> and Temporary Internet Files. Due to the nature of a utility we're using
>> to manage client PCs, this script will run as a scheduled task with admin
>> credentials, and preferably will clear out these files under all profiles
>> on the target system. I know there are other approaches (eg, edit the
>> login script or logoff script), but if someone can get the script below
>> to work (I found it through searches though the poster could not get it
>> to function), it would be greatly appreciated. Or potentially suggesting
>> an alternative script to the one below - whatever works!
>>
>> SET SRC1=C:\Documents and Settings
>>
>> SET SRC2=Local Settings\Temporary Internet Files
>>
>> SET SRC3=Local Settings\Temp
>>
>> FOR /D %%X IN ("%SRC1%\*") DO FOR /D %%Y IN ("%%X\%SRC2%\*.*") DO RMDIR
>> /S /Q "%%Y"
>>
>> 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"
>>
>