How to Modify Windows Registry with VBS

Example 2: Full Script To Remove The Arrow On Shortcuts

Rather than just delete the appropriate Registry value, I have also decided to create a new Registry value. This achieves the illusion of renaming the original value IsShortCut to IsNotShortcut. From a learning point of view, this extra code provides examples of .RegWrite and .RegRead. From a strategic point of view this script introduces primitive error correcting code. In particular the 'If' section, together with On Error Resume Next, copes with the situation where you run the script for a second time.

  • If you have already run Example 1, you may want to run the second .reg file to restore the 'IsShortCut' value.
  • I expect that you have a shortcut on the desktop, if not: right-click, new, shortcut and type 'calc'. Press 'Finish' and the shortcut, complete with arrow will arrive on the desktop.
  • Copy and paste the script below into notepad, or get a script editor such as OnScript.
  • Save the file with .vbs extension e.g. NoArrowEg2.vbs
  • Double click your VBScript, then 'OK' the message box.
  • I recommend that you investigate the Registry section specified by strRoot.
  • Ah yes, to actually see the arrows disappear, simply logoff and logon again. The shortcuts should now have no arrows.

' NoArrowEg2.vbs
' Example VBScript to remove arrows on shortcuts on XP
' and Windows 2003.
' Author Guy Thomas http: //
' Version 2.3 - March 2007
' ---------------------------------------------------------------'
Option Explicit
Dim objShell, strRoot, strRegRead, strNew
Dim strRead, strDelete, strCreate
err.number = 0
strRoot = "HKCR\lnkfile\"
strNew = strRoot & "IsNotShortCut"
strRegRead = strRoot & "IsShortCut"
' Create the Shell object
Set objShell = CreateObject("WScript.Shell")
On Error Resume Next
strRead = objShell.RegRead(strRegRead)
If err.number => 0 then
strCreate = objShell.RegWrite(strNew,"", "REG_SZ")
strDelete = objShell.RegDelete(strRegRead)
End if
WScript.Echo "Error No: " & err.number & " check " & strRoot
On Error GoTo 0
strCreate = null
strDelete = null

' End of example script.

Learning Points
  1. The If err.number section has primitive error correcting code to prevent the script halting if you run it for a second time.
  2. RegWrite also has the implicit create property. Observe how it creates the parent value, and then assigns it a value. To emphasise the point, before the script runs for the first time, there is no 'IsNotShortCut' value. Yet thanks to .RegWrite a new REG_SZ called 'IsNotShortCut' is added to the Registry with a null value (""). A null value can actually be checked for in statements such as the "If" statement.
  3. The RegDelete method deletes an entry from the Registry based on strName. If strName ends with a backslash (\), then strName is treated as a key, otherwise it is treated as a value.
  4. For completeness, you may wish to find other instances of IsShortCut, for example at: HKCR\piffile and HKCR\WSHFile.
Create a new thread in the US Reviews comments forum about this subject
This thread is closed for comments
No comments yet
    Your comment