Coming Soon: GET:IT Endpoint Management 1-Day Conference on September 28th at 9:30 AM ET Coming Soon: GET:IT Endpoint Management 1-Day Conference on September 28th at 9:30 AM ET
Windows Server 2008

Delete IE7 History From the Command Line

When cloning a computer running Windows XP, 2003, Vista or 2008, one of the tasks that you should perform before running SYSPREP is to delete the Internet Explorer 6 history, stored passwords, offline files and cookies. Same goes when preparing a computer for transfer to another user, or simply requiring that previous user data be deleted.

Through the usual IE GUI

One method of performing this task is by using the IE7 GUI.

Open Internet Explorer, and from the Tools menu, open Internet Options.

Sponsored Content

Say Goodbye to Traditional PC Lifecycle Management

Traditional IT tools, including Microsoft SCCM, Ghost Solution Suite, and KACE, often require considerable custom configurations by T3 technicians (an expensive and often elusive IT resource) to enable management of a hybrid onsite + remote workforce. In many cases, even with the best resources, organizations are finding that these on-premise tools simply cannot support remote endpoints consistently and reliably due to infrastructure limitations.

Go to the General tab, and in the Browser History section, click on the Delete button.

In the Delete Browser History window, click one of the following buttons, based upon your requirements:

Temporary Internet Files > Delete files – To delete copies of web pages, images, and media that  are saved for faster viewing.

Cookies > Delete cookies – To delete cookies, which are files stored on your computer by websites to save preferences such as login information.

History > Delete history – To delete the history of the websites you have visited.

Form data > Delete forms – To delete all the saved information that you have typed into forms.

Passwords > Delete passwords – To delete all the passwords that are automatically filled in when you log on to a website you’ve previously visited.

Delete all – To delete all of the above in one operation.

By using a command

However, sometimes it is much easier to simply run a command line command or batch file to perform the same tasks. I use such a batch file and place it in one of my “special scripts” folder, where I store all my cool stuff. All I have to do is simply double-click on it, and bingo, history, passwords, cookies and offline files are deleted.

Here are the independent commands you can use. Go to Start > Run. Type CMD and press Enter. In the Command Prompt window, type (or copy and paste) the following commands, and press Enter:

Delete Temporary Internet Files

​RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 8

Delete Cookies

​RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 2

Delete History

​RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 1

Delete Form Data

​RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 16

Delete Stored Passwords

​RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 32

Delete All

​RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 255

Delete All with the “Also delete files and settings stored by add-ons” options selected

​RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 4351

Now it seems that the interesting bit is that you can combine the numbers to get 2 or more functions at the same time. For example, type:

​RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 9

This will delete the files (+8) and history (+1) in one step. You can incorporate this into a logoff script, and assign it to users by using Group Policy (GPO).

Creating a shortcut

You can create a shortcut and place it on your desktop or Quick Launch toolbar.

Right-click on an empty spot on your desktop, select New > Shortcut.

In the Create Shortcut window, paste one of the above commands.

Give it an appropriate name, and press Finish.

You can also change the shortcut icon by right-clicking on it and selecting Properties. Next press the Change Icon button.

You can use the following file to find some interesting icons for the shortcut:


Creating a batch file

You can also create a batch file that you can simply run by double-clicking on it. Save the following text as a .BAT file:

ECHO Deleting current user's Temporary Files, Cookies, History, Form Data and Stored Passwords
RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 1
RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 2
RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 8
RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 16
RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 32
RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 255
ECHO Done!

Second example uses e different approach, but it’s also worth noting:

ECHO Cleaning Current User's Temp Folders
FOR /D %%G IN ("C:'Documents and Settings'*.*") DO DEL/S/Q/F "%%G'Cookies'*.*"
FOR /D %%G IN ("C:'Documents and Settings'*.*") DO DEL/S/Q/F "%%G'Local Settings'Temp'*.*"
FOR /D %%G IN ("C:'Documents and Settings'*.*") DO DEL/S/Q/F "%%G'Local Settings'History'*.*"
FOR /D %%G IN ("C:'Documents and Settings'*.*") DO DEL/S/Q/F "%%G'Local Settings'Temporary Internet Files'*.*"
ECHO Done!

Recent Windows Server 2008 Forum threads

Got a question? Post it on our Windows Server 2008 forums!

Related Topics:

Live Webinar: Active Directory Security: What Needs Immediate Priority!Live on Tuesday, October 12th at 1 PM ET

Attacks on Active Directory are at an all-time high. Companies that are not taking heed are being punished, both monetarily and with loss of production.

In this webinar, you will learn:

  • How to prioritize vulnerability management
  • What attackers are leveraging to breach organizations
  • Where Active Directory security needs immediate attention
  • Overall strategy to secure your environment and keep it secured

Sponsored by: