Tuesday, January 31, 2006

Logoff Script to delete Temporary Internet Files, History and Cookies

I've shown my wife on multiple occasions how to do IE maintenance on her computer. She just can't seem to grasp the concept. Her computer is not the fastest thing in the world (It's a PIII 800), but she only uses it for e-computing (Ebay, Email, E-Mule). So instead of just getting angry with her when she complains about her computer slowing down because she has a million files in her Temporary Internet Files folder, I wrote a logoff script and applied it to her computer. This is how I did it.

First of all, my Logoff Script includes the use of sdelete.exe from sysinternals.com. If you don't have this, download it and install the executable in your c:\windows\system32 directory.
The Logoff Script deletes everything in the temp folders, the Temporary Internet Files folder, purges the history, and deletes all cookies. It also creates a log file showing when the logoff script was last run. You can download my logoff script from HERE. This is basically the same script that I posted earlier in my Secure Desktop post.

Take the batch file and copy it in your %SystemRoot%\system32\GroupPolicy\User\Scripts\Logoff directory. You may not have the "Scrpts\Logoff" part of this path, if you don't, create these directories so you have this full path.

Now let's edit the Group Policy for this workstation.

1. Login as a local Administrator
2. Click on the start menu and select "Run"
3. Type "gpedit.msc" - this will open the Group Policy Editor
4. Under "User Configuration", expand the "Windows Settings"
5. Click on "Scripts"
6. In the right pane, double click "Logoff", this will open the "Logoff Properties"
7. Now we need to add the batch file, click on "Add", The "Add a Script" box will appear
8. Click "Browse" and select the batch file.
9. Hit OK and then close everything including the Group Policy Editor

Your logoff script in now set to run whenever you logoff the computer.
Now the problem is forcing her to logoff now and then. My wife doesn't do this, so I created a scheduled task that does it for her. I Create a new scheduled task. I put "C:\WINDOWS\system32\logoff.exe" in the run menu, I scheduled it to run weekly at about 4:00 AM. I also set the job to make sure that the computer has been idle for at least an hour before it tries to logoff.


Anonymous said...

Thank you.
This helpes me from having to do it all the time.

Anonymous said...

Your wife is stupid!
I hope shes at least good on the bed.