Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

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

Posted on 2008-11-13
9
Medium Priority
?
893 Views
Last Modified: 2013-12-05
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.  
0
Comment
Question by:Itsa56
  • 5
  • 4
9 Comments
 
LVL 3

Expert Comment

by:haldoxp
ID: 22958082
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
 

Author Comment

by:Itsa56
ID: 22965602
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
 
LVL 3

Expert Comment

by:haldoxp
ID: 22972414
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:Itsa56
ID: 22982350
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
 
LVL 3

Expert Comment

by:haldoxp
ID: 22982556
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
 

Author Comment

by:Itsa56
ID: 23038991
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
 
LVL 3

Accepted Solution

by:
haldoxp earned 1500 total points
ID: 23075969
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
 

Author Comment

by:Itsa56
ID: 23101826
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
 

Author Closing Comment

by:Itsa56
ID: 31516661
I've taken most part of your solution. Thanks again for your help.
0

Featured Post

Configuration Guide and Best Practices

Read the guide to learn how to orchestrate Data ONTAP, create application-consistent backups and enable fast recovery from NetApp storage snapshots. Version 9.5 also contains performance and scalability enhancements to meet the needs of the largest enterprise environments.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Group policies can be applied selectively to specific devices with the help of groups. Utilising this, it is possible to phase-in group policies, over a period of time, by randomly adding non-members user or computers at a set interval, to a group f…
The article explains the process to deploy a Self-Service password reset portal I developed a few years ago. Hopefully, it will prove useful to someone.  Any comments, bug reports etc. are welcome...
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…
Suggested Courses

580 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question