Can we delete user's temp internet file during system context installation?
I am trying to delete all user's temp internet files via custom action. I used vbscript to do so. But as we know, it requires logoff and login for system context installation.
Is there any other way to delete the user's temp internet files without logoff? And silently during system context installation?
Answers (3)
Finally i used the below script in cmd file. @echo off IF NOT EXIST "%SystemDrive%\Users\" ( for /D %%x in ("%SystemDrive%\Documents and Settings\*") do ( rmdir /s /q "%%x\Local Settings\Temporary Internet Files" ) ) IF EXIST "%SystemDrive%\Users\" ( for /D %%x in ("%SystemDrive%\Users\*") do ( rmdir /s /q "%%x\AppData\Local\Microsoft\Windows\Temporary Internet Files" ) ) To call the cmd file silently in vbscript custom action, i used the below script On error resume next Set WshShell = CreateObject( "WScript.Shell" ) Set objFSO = CreateObject("Scripting.FileSystemObject") strPrgf=WshShell.ExpandEnvironmentStrings("%PROGRAMFILES%") strPrgfx86=WshShell.ExpandEnvironmentStrings("%PROGRAMFILES(X86)%") dest=strPrgf & "\cleanup.cmd" dest2=strPrgfx86 & "\cleanup.cmd" if objFSO.FolderExists(strPrgfx86) then Set WshShell = CreateObject("WScript.Shell" ) WshShell.Run chr(34) & dest2 & Chr(34), 0 Set WshShell = Nothing Else Set WshShell = CreateObject("WScript.Shell" ) WshShell.Run chr(34) & dest & Chr(34), 0 Set WshShell = Nothing End if
You can write a VBScript which will read the userprofile's folder names under C:\Users except Default and Public folder and delete the Temp files under each users profile's folder
Finally i used the below script in cmd file.
@echo off
IF NOT EXIST "%SystemDrive%\Users\" (
for /D %%x in ("%SystemDrive%\Documents and Settings\*") do (
rmdir /s /q "%%x\Local Settings\Temporary Internet Files"
)
)
IF EXIST "%SystemDrive%\Users\" (
for /D %%x in ("%SystemDrive%\Users\*") do (
rmdir /s /q "%%x\AppData\Local\Microsoft\Windows\Temporary Internet Files"
)
)
To call the cmd file silently in vbscript custom action, i used the below script
On error resume next
Set WshShell = CreateObject( "WScript.Shell" )
Set objFSO = CreateObject("Scripting.FileSystemObject")
strPrgf=WshShell.ExpandEnvironmentStrings("%PROGRAMFILES%")
strPrgfx86=WshShell.ExpandEnvironmentStrings("%PROGRAMFILES(X86)%")
dest=strPrgf & "\cleanup.cmd"
dest2=strPrgfx86 & "\cleanup.cmd"
if objFSO.FolderExists(strPrgfx86) then
Set WshShell = CreateObject("WScript.Shell" )
WshShell.Run chr(34) & dest2 & Chr(34), 0
Set WshShell = Nothing
Else
Set WshShell = CreateObject("WScript.Shell" )
WshShell.Run chr(34) & dest & Chr(34), 0
Set WshShell = Nothing
End if
If you are talking IE this will do it for current user
RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 255
Comments:
-
for others this may help
http://www.catonmat.net/blog/clear-privacy-ie-firefox-opera-chrome-safari/
http://ie-support.blogspot.com/2011/02/use-command-line-to-delete-ie-browsing.html - SMal.tmcc 11 years ago -
Thanks Steve. Can this be done silently? - blask28 11 years ago
-
not that I am aware of, look at this link and one response (30Aug2012 11:41) explains why and later someone mentions some other software.
http://www.autoitscript.com/forum/topic/143786-clearing-internet-explorer-history/ - SMal.tmcc 11 years ago