Temporary Internet Files and temp files deletion scrpt
-
Thursday, July 08, 2010 8:13 AM
I have windows 7 and windows XP systems in my domain environment. I want one scrpt which can be put in the log off script for the deletion of temporary internet files and the temp files from the profiles?
Have tried below commands in batch file but those only work when browser window is open:
RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 2
History
RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 1
Form Data
RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 16
Passwords
RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 32
Delete All
RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 255
Delete All - "Also delete files and settings stored by add-ons"
RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 4351Also tried using GPO to configure IE to delete it's browsing history upon exit. 'computer configuation - administrative templates - Windows components - Internet explorer - delete browsng history'. but cold not find this option in GPO?
Can someone help me on this?
STeve
All Replies
-
Thursday, July 15, 2010 4:12 PM
I found this cookie-clearing script on Richard Siddaway's Blog, which may help: http://msmvps.com/blogs/richardsiddaway/archive/2010/07/12/cookie-time.aspx
$app = New-Object -ComObject Shell.Application Get-ChildItem $app.namespace(0x21).Self.Path | Remove-Item
0x20 is Temporary Internet Files, 0x22 is History, etc.
- Proposed As Answer by Newbie x2 Friday, July 16, 2010 12:24 AM
- Marked As Answer by Boe ProxModerator Monday, September 06, 2010 9:48 PM
-
Friday, July 16, 2010 12:28 AM
$app = New-Object -ComObject Shell.Application
Get-ChildItem $app.namespace(0x21).Self.Path | Remove-Item0x20 is Temporary Internet Files, 0x22 is History, etc.
Nice one!
Any way to run script as LocalSystem or some other account and clear temp stuff for all users?
-
Friday, July 16, 2010 1:51 AM
$app = New-Object -ComObject Shell.Application
Get-ChildItem $app.namespace(0x21).Self.Path | Remove-Item0x20 is Temporary Internet Files, 0x22 is History, etc.
Nice one!
Any way to run script as LocalSystem or some other account and clear temp stuff for all users?
I would start by trying something like this:
gci c:\users | foreach {gci "$($_.fullname)\AppData\Local\Microsoft\Windows\Temporary Internet Files" | Remove-Item}
-
Friday, July 16, 2010 2:12 PM
I’m looking for something very simple (one or “one and half” line ;-)
>0x20 is Temporary Internet Files, 0x22 is History, etc.
0x20, 0x21, 0x22 | % { Get-ChildItem $app.namespace($_).Self.Path } | Remove-Item
-
Monday, July 19, 2010 5:42 PM
this has not solved by purpose, I want to run a script in a domain which consists on more than 120 systems.
steve
-
Sunday, August 22, 2010 9:12 AMModerator
Why didn't that solve you problem?
Newbie x2's powershell script run as logoff script should do the trick
$app = New-Object -ComObject Shell.Application 0x20, 0x21, 0x22 | % { Get-ChildItem $app.namespace($_).Self.Path } | Remove-Item
-
Monday, August 23, 2010 4:04 AMModerator
this has not solved by purpose, I want to run a script in a domain which consists on more than 120 systems.
steve
Your best bet is using a GPO log off script that runs when a user logs off. The key thing is to have powershell installed on each system so you can configure and run the script that Newbie x2 found. This won't work any other way because the user needs to be authenticated with the computer and the COM object being used does not support remote machines, only local. -
Monday, August 23, 2010 4:34 PM
Your best bet is using a GPO log off script that runs when a user logs off. The key thing is to have powershell installed on each system so you can configure and run the script that Newbie x2 found. This won't work any other way because the user needs to be authenticated with the computer and the COM object being used does not support remote machines, only local.
Agreed. Script has to use COM object, because user can remap any [temporary] folder to an arbitrary path. So it has to run within user context. And GPO logout policy is the best way, IMO.
Once user logged out – his temporary stuff is deleted right away ;-)
-
Wednesday, September 01, 2010 8:31 AMModeratorHi.
It has been a week since the last post. Please mark the topic as answered or post back some problems you had.
If you don't post back in a week, we will assume the topic has been answered.
Best regards
Oliver Lipkau
Moderator

