Jump to content

Deleting IE Temp and History


kpu
 Share

Recommended Posts

Hey All,

I've been using Auto It for little things here and there and I'm tring to do the following.

I need to clear the History of IE after it closes. We have people who use our company PC's for personal use, which is allowed, and I need to be able to clear the cache (History, Temp, and Cookies) after the IE is closed. For some reason I can't get it to delete the History of the users profile. I found this topic at Microft as well.Microsoft Topic

I've seen someones else's code that does this, it was more complex, but I can't find it. :idiot:

Can someone please give me some pointers. I wrote the code with MsgBox's so I know where it is in the code. Here is what I have so far. Also, if anyone knows where else I should delete files from, please fill me in.

ProcessWait("IEXPLORE.exe")
MsgBox(0,"Internet", "Iexplore is present","")
ProcessWaitClose("IEXPLORE.exe")
MsgBox(0,"Internet", "Iexplore is not present","")

;--------DELETE HISTORY----------------------->
$hisdelete = FileDelete(@UserProfileDir & "\Local Settings\History\*.*")
if $hisdelete = "0" Then 
    MsgBox(0,"","History File's weren't deleted","")
    
Else
    MsgBox(0,"","History File was deleted","")
EndIf

;--------DELETE TEMP FILES---------------------->
$Tempdelete = FileDelete(@UserProfileDir & "\Local Settings\Temp\*.*")
if $Tempdelete = "0" Then 
    MsgBox(0,"","Temp File's weren't deleted","")
    
Else
    MsgBox(0,"","Temp File was deleted","")
EndIf

;--------DELETE TEMP INTERNET FILES-------------->
$TempIEdelete = FileDelete(@UserProfileDir & "\Local Settings\Temporary Internet Files\*.*")
if $TempIEdelete = "0" Then 
    MsgBox(0,"","Temp Internet File's weren't deleted","")
    
Else
    MsgBox(0,"","Temp Internet File was deleted","")
EndIf

;--------DELETE COOKIES-------------------------->
$TempCdelete = FileDelete(@UserProfileDir & "\Cookies\*.txt")
if $TempCdelete = "0" Then 
    MsgBox(0,"","Cookies weren't deleted","")
    
Else
    MsgBox(0,"","Cookies was deleted","")
EndIf

;--------DELETE Typed URLs FROM REGISTRY-------------------------->
$DelReg = RegDelete("HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\TypedURLs",)
if $DelReg = "2" Then
    MsgBox(0,"","RegKey Delete Didn't work","")
Else
    MsgBox(0,"","RegKey was deleted","")
EndIf
Exit

Oh, and before I forget. I need to run this with admin rights. Is there a way to do that without building another script using the "RunAsSet" command from another script calling this script? So, lets say the code above is compiled to an executable called . "IE2.exe" Below is how I've normally done it..

RunAsSet("Administrator", @Computername, "adminpassword")

RunWait("IE2.exe")

RunAsSet()

Thanks!

Edited by kpu
Link to comment
Share on other sites

Interesting... No one has any comments...  :idiot:

<{POST_SNAPBACK}>

I enjoyed your script, but is not better to config every pc through registry to clear history of the Internet Explorer. Windows do it automatcly if you wish.
Autoit.es - Foro Autoit en Español Word visitors Image Clustrmap image: - Football Spanish team - Spanish team: Casillas, Iniesta, Villa, Xavi, Puyol, Campdevilla, etc..Programando en Autoit+Html - Coding Autoit-Html - Arranca programas desde Internet - Preprocesador de Autoit a http
Link to comment
Share on other sites

Does anyone know the command to lauch the the clear history using the Rundll32.exe

Example: Here's how you can launch the IE Properties page in XP.

"C:\WINDOWS\system32\rundll32.exe" /d shell32.dll,Control_RunDLL INETCPL.CPL

I'm almost positive XP uses some kind of command to delete the files.. Just WHAT!!! :idiot:

Link to comment
Share on other sites

No command, as far as I know.

It uses a key in the registry, I can't remember exactly, may be in Policy, but you can find it easily.

Does anyone know the command to lauch the the clear history using the Rundll32.exe

Example: Here's how you can launch the IE Properties page in XP.

"C:\WINDOWS\system32\rundll32.exe" /d shell32.dll,Control_RunDLL INETCPL.CPL

I'm almost positive XP uses some kind of command to delete the files.. Just WHAT!!!  :idiot:

<{POST_SNAPBACK}>

Edited by BasicOs
Autoit.es - Foro Autoit en Español Word visitors Image Clustrmap image: - Football Spanish team - Spanish team: Casillas, Iniesta, Villa, Xavi, Puyol, Campdevilla, etc..Programando en Autoit+Html - Coding Autoit-Html - Arranca programas desde Internet - Preprocesador de Autoit a http
Link to comment
Share on other sites

I did this quite a while back for PCs at my old place of work before I got made redundant - the site used a web based mail system and when PCs got infected with a worm that scanned HTML files for E-mail addresses it started to spread internally 'cos the pratts who setup the mail server turned off authentication. Anyway its OLD but you may find some handy pointers + remember it was for PCs running W2K. It may be better writing something which fires off MS delprof prog instead...

Note this is using Ver2 of Autoit.

; Program that Deletes Users History & Cache Files To Prevent Worm E-Mail address Scans

; Version 1.0

; Written By Matt

; Created March 22nd 2004

; Last updated March 2004

;Display Message Box

MsgBox, 4, Cache Delete Program. Written By Matt.  March 2004, This will Delete your Internet Cache, Suspect & History files to prevent E-mail address scans from taking place on your device. Please note only the ID's files thats currently logged on will be removed. Continue ?

IfMsgBox, No, Goto, quit

Splashtexton, 300, 100, Cache Delete Program, Deleting your History, Suspect and Internet Cache Files. Please wait.

IfExist, c:\\OFFICESCAN NT ,goto, check

Ifnotexist, C:\\OFFICESCAN NT ,goto, cache

check:

Runwait, %COMSPEC% /C DEL C:\\"officescan nt"\\suspect\\*.* /f /s /q /a R S H

  Sleep, 5000

cache:

Runwait, %COMSPEC% /C DEL C:\\"documents and settings"\\%username%\\"local settings"\\*.* /f /s /q /a R S H

  Sleep, 3000

    Splashtextoff

;Final Message

MsgBox, 0, Cache Delete Program, Deletion of Files Sucessful.

Exit

quit:

Exit

Link to comment
Share on other sites

Well, I have a found a solution to this. I still have one issue though. I can't get the "Clean manager" window to move. I had it working, and then it would work. If anyone knows why, please let me know.

MattX, Thanks for your code as well. I haven't tried it, but I'm sure it will work too.

Here it is.

Changes in Internet Explorer

--------------------------------------------------------------------------------

1. In Internet Properties, click on the "General" Tab, Click "Clear History", the change the amount of days to keep in history to "0".

2. In Internet Properties, click on the "Content" Tab, then click on "AutoComplete.." Uncheck the boxes for "Web Address", "User names and passwords on forms", and "Prompt me to save passwords".

3. In Internet Properties, click on the "Advanced" Tab, under the "Security" section. Check and the box for "Empty Temporary Internet Files folders when browser is closed". (I had to uncheck, click "Apply". Then check and click "Apply" for this to work.)

4. Remove the "History" button in IE. (I think I did this, but I will have to check)

Registry Changes

--------------------------------------------------------------------------------

1. Change the permissions on "HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\TypedURLs" to "Deny" for the user.

My Little Program

--------------------------------------------------------------------------------

1. At the command prompt run the following command. "cleanmgr /sageset:1". This will bring up the Clean Manager. Select what Items you want to delete. I chose everything except for "Compressed Files".

2. Copy "IE MOD.exe" and "IEXPLORE2.EXE" to "C:\Program files\Internet Explorer"

3. Change the Internet Explorer link so it points to "IEXPLORER.EXE" to "IEXPLORE2.EXE"

What my Program Does

--------------------------------------------------------------------------------

"IE MOD.exe" launches "IEXPLORER.EXE" with admin rights. This is so it will be able to run the Clean Manager. The command "cleanmgr /sageset:1" sets what files it will cleanup or delete.

"IEXPLORER2.EXE" waits for "IEXPLORE.EXE" process to end. It then will then launch "cleanmgr /sagerun:1" which will then delete the selected files with the first command.

CODE FOR "IE MOD.exe"

AutoItSetOption ( "TrayIconHide", 1)
RunAsSet("Administrator", @Computername, "adminpassword")

RunWait("IEXPLORE2.exe")

RunAsSet()

CODE FOR IEXPLORE2.EXE

run("iexplore.exe")
ProcessWait("IEXPLORE.exe")
ProcessWaitClose("IEXPLORE.exe")
Sleep(1000)

;--------DELETE Typed URLs FROM REGISTRY-------------------------->
RegDelete("HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\TypedURLs",)

;-------RUNS CLEANUP MANAGER WITH "/SAGERUN:1" ON THE END OF IT.
run("cleanmgr /sagerun:1","c:\windows\system32\",)

WinWaitActive("Disk Cleanup","")
sleep(1500)
WinMove( "Disk Cleanup", "" , @desktopHeight, 0 , "" )
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...