Logoff script with deleting cookies, temp and recent files and internet tem file

My  network platform is MS2003 server AD installed and all workstation are XP SP2 pro. All users have roaming profile. I'm an administrator and have a Domain admin account. I'd like to create a script to delete COOKIES, TEMP files, RECENT DOCUMENTS and INTERNET TEMP FILES when users logoff or before profile  transfers to server. I have more than 500 users therefore I prefer to put in logoff script policy. Could expert exchange help me please.
PS. I'm pretty dump with scripting and apply policy to OU.  
Itsa56Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

haldoxpCommented:
A year ago I wrote this very basic script. Now I'm sure it can be done more nicer but it is working :). I implemented this into log on script and no problem.
cd C:\Documents and Settings\username\Recent\
del *.* /F /S /Q
cd C:\WINDOWS\Temp\
del *.* /F /S /Q
cd C:\Documents and Settings\username\Local Settings\Temp\
del *.* /F /S /Q

Open in new window

0
Itsa56Author Commented:
Thanks for showing me script.
1. how this script will work with every user when they logon and off. Do I need to put variable to username as ....\%username%\.......
2.  since we've used logon and off policy in the profile how can I apply this script to the policy.
3. how can I apply this script for test user first, before rollout to 500 users.
4. attached is a user property from our AD FYI.
5. Does the script above covers delete cookies?

User-Property.doc
0
haldoxpCommented:
1. you can use %userprofile% variable (see the link below)
2. just add this to your script
3. create script and run it under the test user. 2nd choise is to create TEST OU, move test user into this OU and assign GPO.
5. no, cookies are located in "%USERPROFILE%\Cookies\". For Temporary Internet Files the path is "%USERPROFILE%\Local Settings\Temporary Internet Files". There is no environment variable in XP for that path by default.

Default Values on Microsoft Windows
http://en.wikipedia.org/wiki/Environment_variable#Default_Values_on_Microsoft_Windows
cd %userprofile%\Recent
del *.* /F /S /Q
cd %userprofile%\Local Settings\Temp
del *.* /F /S /Q
cd %USERPROFILE%\Local Settings\Temporary Internet Files
del *.* /F /S /Q
cd %USERPROFILE%\Cookies
del *.* /F /S /Q

Open in new window

0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

Itsa56Author Commented:
Haldoxp,
1.  I've tried to fit your script  in my environment. Could you check for me please, before I make a batch file and put in the logoff script policy? I've also attached user profile hierarchy, I've made a circle in COOKIES, TEMP, TEMPORARY INTERNET FILES and RECENT where I want to delete files under these folders while users logoff from network.
 
@ECHO OFF
REM# DELETE "COOKIES"
CD Documents and Settings\%username%\Cookies
DEL *.* /F /S /Q
REM# DELETE "TEMP"
CD Documents and Settings\%username%\Local Settings\Temp
DEL *.* /F /S /Q
REM# DELETE "TEMPORARY INTERNET FILES"
CD Documents and Settings\%username%\Local Settings\Temporary Internet Files
REM# DELETE "Recent"
CD Documents and Settings\%username%\Recent
DEL *.* /F /S /Q
Exit

2. Could you tell me how to put this batch file to logoff policy in AD please.
Thanks
Snapshot-profile.JPG
0
haldoxpCommented:
Use %userprofile$%, see my last post.

For log on / log off scripts, see e.g http://technet.microsoft.com/en-us/library/cc781354.aspx
0
Itsa56Author Commented:
haldoxp,
1. It could not delete files under Temporary Internet Files with the script below.
cd %USERPROFILE%\Local Settings\Temporary Internet Files
del *.* /F /S /Q
After testing a few time it shows script can't delete 1 file and then throws out. It's possible to make a loop in script to keep deleting the rest of files.
2. some my users have folder calls "Recent" some have "My recent documents" . What should I add this script:
cd %userprofile%\Recent
del *.* /F /S /Q
0
haldoxpCommented:
1. the script just skips 1 file or ends? If the file is in use then it will not be deleted.
2. you can create new variable %recent% on each PC and then use this path

del %recent%\*.* /f /s /q
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Itsa56Author Commented:
1. In relation to my question 1. The script has deleted Temporary Internet Files, but it takes 4 or 5 min to produce an effect. And it's not working when Internet browsers are open. It's anyway or switch to make faster iterm of deleting files
2. the new variable %recent% is working.
0
Itsa56Author Commented:
I've taken most part of your solution. Thanks again for your help.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Server OS

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.