Our
mission is to create a script that will change values in the registry.
Once you have mastered the technique, the scope for registry scripting is nearly
as big as the registry itself. The mission will be tricky, success will
depend on attention to detail.
To complete our mission, we are going to need to combine skills from VBScript (WSH), Windows 2003/8 (Windiff, the registry (Regedit, Active Directory (LDAP). In
truth, I selected this key for you to experiment with scripting the registry using a relatively harmless key.
Example - To Empty Temporary Internet Files folder
The
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:
Change the settings in Internet Explorer, specifically to put a tick in this box: 'Empty Temporary Internet Files
folder when browsing'.
Next, over to Regedit. Navigate to the section of the registry where that
setting is likely to be found. 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 and remove the tick from the Export Temporary...
checkbox.
Back to Regedit and Export again, this time give your export file a different, e.g. - notick.reg.
Remember that the Goal was to make sure that the Internet Explorer deleted all temporary
files on exit. We want a script which does the same as manually clicking, 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"
' VBScript - contact guy@computerperformance.co.uk
' 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 objShell, RegLocate, RegLocate1
Set objShell = 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\
objShell.RegWrite RegLocate,"0","REG_DWORD"
WScript.Quit ' Tells the script to stop and exit.
Guy
Recommends: Permissions Analyzer - Free Active Directory Tool
I like the
Permissions Monitor because it enables me to see quickly WHO has permissions
to do WHAT. When you launch this tool it analyzes a users effective NTFS
permissions for a specific file or folder, takes into account network share
access, then displays the results in a nifty desktop dashboard!
Think of all the frustration that this free utility saves when you are
troubleshooting authorization problems for users access to a resource.
Windows Management Instrumentation (WMI) is one of the hidden
treasures of Microsoft operating systems.
Fortunately, SolarWinds
have created the
Free WMI Monitor so that you can actually see and understand these gems of
performance information. Take the guess work out of which
WMI counters to use for applications like Microsoft Active Directory,
SQL or Exchange Server.