Change Registry Settings Internet Temporary Files

VBScript to change the registry settings

The goal of this page is to combine skills using VBScript, WinDiff and Regedit.  Our mission is to change values in the registry.  We need to find the correct registry hive, then create a script to make the change automatically.  This mission is difficult and success will depend on attention to detail.

Scenario to Empty the Temporary Internet Files folder

Regedit Empty Temporary Internet filesThe scenario is this, we need to control the follow setting in the browser –  ‘Empty Temporary Internet Files folder when browsing’ .

WinDiff and Regedit

The method we are going to use involves exporting a section of the registry.  In fact we will export the section twice, once with setting on (checked) and once with the setting off (unchecked). 

Now we are ready to open the WINDIFF utility an detect the difference in the two files.  Once we locate the differences between the checked and unchecked files we will know where in the registry the setting is located.

Here is the technique I used:

  1. Change the settings in Internet Explorer – ‘Empty Temporary Internet Files folder when browsing’ so that there is a tick in the box.
  2. Over to Regedit.  Navigate to the section of the registry where that setting is likely to be. HKEY_CURRENT_USER_Software_Microsoft, right-click, then Select Export on the shortcut menu.  Choose a suitable filename e.g. tick.reg. 
  3. Then go to Internet explorer remove the tick from the Export Temporary… checkbox.
  4. Back to Regedit and Export again, this time name your file – notick.reg.
  5. Finally, launch WINDIFF open both files and spot the changes in the two files.  Here is a link for your copy of WINDIFF

Empty Temporary Internet FilesThe Goal was to make sure that the Internet Explorer deleted all temporary files on exit. IE, Tools, Internet Options, Advanced, Security, Empty Temporary Internet Files on Exit.

RegWrite – WSH Method

The actual scripting part is controlled by a method called RegWrite.  Once WINDIFF told me the correct registry path, it is a matter of taking care with the syntax and using REG_DWORD (not REG_SZ).

There was one last trap to get the tick to appear in Internet Explorer you need to set Persistent = 0.  The logic is we do not want any files saved – hence zero.  "HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\Cache\Persistent"

Solarwinds Config GeneratorGuy Recommends: The Free Config Generator

SolarWinds’ Config Generator is a free tool, which puts you in charge of controlling changes to network routers and other SNMP devices.  Boost your network performance by activating network device features you’ve already paid for.

Guy says that for newbies the biggest benefit of this free tool is that it will provide the impetus for you to learn more about configuring the SNMP service with its ‘Traps’ and ‘Communities’. Try Config Generator now – it’s free!

Download your free copy of Config Generator

VBScript code:

‘ VBScript – contact [email protected]
‘ The script writes to the registry value Empty Temporary Internet Files
‘ The key Method is RegWrite.  RegLocate is the name of the variable
‘ Note: REG_DWORD (not REG_SZ)
‘ Note: Logic of 0 (zero = off) means persistent ON – strange but true!

Dim WSHShell, RegLocate, RegLocate1
Set WSHShell = WScript.CreateObject("WScript.Shell")
On Error Resume Next
RegLocate = "HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\Cache\Persistent"
‘ Take great care with the line above
‘ Note the space between \Internet and Settings\

WSHShell.RegWrite RegLocate,"0","REG_DWORD"

WScript.Quit ‘ Tells the script to stop and exit.
 

Traps for your Script:  Empty Temporary Internet Files

  1. HKEY_Current_User (not HKEY_Local_Machine)
  2. Internet Settings\cache (not Internet\Cache)
  3. Persistent is added to the last part of the path \Cache\Persistent
  4. Persistent = 0 (Not =1)

Monitor Your Network with the Real-time Traffic AnalyzerSolarwinds Real-time Traffic Analyzer

The main reason to monitor your network is to check that your all your servers are available.  If there is a network problem you want an interface to show the scope of the problem at a glance.

Even when all servers and routers are available, sooner or later you will be curious to know who, or what, is hogging your precious network’s bandwidth.  A GUI showing the top 10 users makes interesting reading.

Another reason to monitor network traffic is to learn more about your server’s response times and the use of resources.  To take the pain out of capturing frames and analysing the raw data, Guy recommends that you download a copy of the SolarWindsfree Real-time NetFlow Analyzer.


See Also