Nasty code!

Soldato
Joined
6 May 2009
Posts
20,330
I added this to a logon script yesterday. Its supposed to delete all temp internet files within folders to remove stuff like outlook OLK temp files


if exist "C:\Documents and Settings\%username%\Local Settings\Temporary Internet Files\*.*" (
cd "C:\Documents and Settings\%username%\Local Settings\Temporary Internet Files\*"
del *.* /s /f /q
)

What it actually does is remove all files from temp internet files and users personal U:\ drives files. :eek: Not the folders, just the files. What part of the script specifies it should remove u:\ data??

Currently in the process of restoring a mass of personal data, luckily i caught it before around another 50 people logged in.

Just noticed in active directory under profile settings is the login script that had the code in. Underneath this is the home folder where it connects to U:\
How did the script tie the two together?
 
Last edited:
The CD command has a asterisk symbol at the end, probably causing it to fail and therefore leave the current directory unchanged (in one of your user's case this just happened to be U:\)... also there is no need to check the existance of the directory... it always exists. If there are no files to delete then the DEL command will just do nothing.

Try it like this instead:

Code:
del "C:\Documents and Settings\%username%\Local Settings\Temporary Internet Files\*" /s /f /q

PS: You know there is a group policy setting for purging the temporary internet files when the user logs off, yes?
 
Thanks Nathan. With a simple C: above the code it works. If the C: is not in it removes everything from U: but not C:. With the C: in it removes from C: and not U

Your more simple line also works. Where is the group policy setting for purging temporary internet files? It mainly needs to clear the content.outlook folder

C:
if exist "C:\Documents and Settings\%username%\Local Settings\Temporary Internet Files\*.*" (
cd "C:\Documents and Settings\%username%\Local Settings\Temporary Internet Files\*"
del *.* /s /f /q
)
 
It's because the users current logged drive is U: so the preceding check works, the cd in theory works but it won't changed the current logged drive, just changes the directory for when you get to the drive, which leaves the del command which doesn't care what folder you run the command in.

I'd always advise against doing a del *.* like that without explicit pathing.

Learned the horrible way in my unix days of doing a rm -r * thinking I was in 1 directory when I was actually in /usr/bin
 
Last edited:
Back
Top Bottom