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
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:
- Change the settings in Internet Explorer – ‘Empty Temporary Internet Files folder when browsing’ so that there is a tick in the box.
- 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.
- Then go to Internet explorer remove the tick from the Export Temporary… checkbox.
- Back to Regedit and Export again, this time name your file – notick.reg.
- Finally, launch WINDIFF open both files and spot the changes in the two files. Here is a link for your copy of WINDIFF
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 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!
‘ VBScript – contact email@example.com
‘ 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\
WScript.Quit ‘ Tells the script to stop and exit.
- HKEY_Current_User (not HKEY_Local_Machine)
- Internet Settings\cache (not Internet\Cache)
- Persistent is added to the last part of the path \Cache\Persistent
- Persistent = 0 (Not =1)
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.