Guy’s Scripting Ezine 136 – How to Remove the Arrow on Shortcuts

Guy’s Scripting Ezine 136 How to Remove the Arrow on ShortcutsHow to Remove Arrows on Shortcuts

Even if you have no interest in VBScript, this ezine will help you remove those annoying arrows on shortcuts.  Thus, in addition to the VBScript code, I have instructions on how to modify the registry with .Reg files. 

Beware, the IsShortCut method works fine for XP and Windows Server 2003, but can produce ugly side-effects in Vista.  Next week I have a separate Shell Icons script to remove the arrows from Vista shortcuts.

 ♣

This Week’s Secret

This Week’s Secret is that I want to lure more people into scripting.  By providing a method to remove one of the most annoying features – Arrows on shortcuts – I hope to encourage people to look at what scripting can offer.

Thanks to the .Reg files supplied, you don’t actually have to study VBScript to get this job done.  However, for regular readers who like to study the VBScript code, you will see how easy it is to create objects.  In this instance the object and its .RegDelete method modify the registry.  It almost goes without saying that in other scripts you can use different methods to automate any task that you can perform through a GUI.

To digress, this week is a classic case of Microsoft having not one, but three ways of configuring a registry setting; VBScript, a .Reg file and of course regedit.

This week’s mission

This Week’s Mission is to remove the arrow from a shortcut’s icon.  My VBScript method, which deletes the IsShortCut value, works for both XP and Vista machines.  However beware, because in Vista, removing this registry value causes problems with shortcuts in the Favorites folder.

For those who just want to remove the arrows quickly, I have a .Reg file.  If you are using my scripts, then the .reg files provide a complimentary method for resetting the registry before you run the script for a second time.

A hidden bonus of using a script to remove the shortcut arrows is that we learn about the full range of registry command: .RegWrite, .RegDelete and .RegRead.

Example 1: Basic script to remove the Arrow on Shortcuts

This script is designed for XP and Windows 2003.  While it will work on Vista, it has ugly side-effects on icons in the Favorites folder. 

Example 1: is relatively simple.  It concentrates on creating objShell and applying the .RegDelete method.  Example 2: is more complex, and introduces limited error correcting code.  Moreover Example 2 creates a substitute REG_SZ value, which is the equivalent of renaming IsShortCut.

Instructions

  1. Preliminary step: In order to give the script a chance, create a shortcut.  For example, at the desktop, right-click, new, shortcut and type ‘calc’.  Press ‘Finish’ and the shortcut, complete with arrow will arrive on the desktop.
  2. Copy and paste the script below into notepad.  Alternatively, get your free trial of OnScript.
  3. Save the file with .vbs extension e.g. NoArrow.vbs
  4. Double click your VBScript, then ‘OK’ the message box.
  5. To help you understand what is happening in the registry, I recommend that you launch regedit and navigate to the section specified by strRoot.
  6. Ah yes, to actually see the arrows disappear, simply logoff and logon again.  The shortcuts should now have no arrows.

‘ NoArrowEg1.vbs
‘ Example VBScript to remove arrows on shortcuts on XP.
‘ Author Guy Thomas http: //computerperformance.co.uk
‘ Version 1.5 – March 2007
‘ —————————————————————‘

Option Explicit
Dim objShell, strRoot, strRead, strDelete, strCreate
strRoot = "HKEY_CLASSES_ROOT\lnkfile\IsShortCut"
‘ Create the Shell object
Set objShell = CreateObject("WScript.Shell")
strDelete = objShell.RegDelete(strRoot)
WScript.Echo "Error No: " & err.number & " check " & strRoot
strDelete = null
WScript.Quit

‘ End of example script.

Learning Points

Note 1: Check how VBScript creates the objShell object, then trace how .RegDelete performs its work on the registry.

Note 2: In VBScript HKEY_CLASSES_ROOT can be abbreviated to HKCR.  (There is also HKLM and HKCU.)  Surprisingly, you cannot use HKCR or HKLM in .Reg files.

Note 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.

Note 4: For completeness, you may wish to find other instances of IsShortCut, for example at: HKCR\piffile and HKCR\WSHFile.

See more on Windows 8 Remove Shortcut Arrow.

Guy Recommends: Tools4ever’s UMRAUMRA The User Management Resource Administrator

Tired of writing scripts? The User Management Resource Administrator solution by Tools4ever offers an alternative to time-consuming manual processes.

It features 100% auto provisioning, Helpdesk Delegation, Connectors to more than 130 systems/applications, Workflow Management, Self Service and many other benefits. Click on the link for more information onUMRA.

Example 2: Full script to remove the Arrow on Shortcuts

This script is designed for XP and Windows 2003.  While it will work on Vista, it has ugly side-effects on icons in the Favorites folder. 

Rather than just delete the appropriate registry value, I have also decided to create a new registry value.  What this is achieves is 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 for situation where you run the script for a second time.

Instructions

  1. If you have already run Example 1, you may want to run the second .Reg file to restore the ‘IsShortCut’ value.
  2. 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.
  3. Copy and paste the script below into notepad.  Alternatively, get your free trial of OnScript.
  4. Save the file with .vbs extension e.g. NoArrow.vbs
  5. Double click your VBScript, then ‘OK’ the message box.
  6. I recommend that you investigate the registry section specified by strRoot.
  7. 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.
‘ Author Guy Thomas http: //computerperformance.co.uk
‘ 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
WScript.Quit

‘ End of example script.

 

Learning Points

Note 1:  The If err.number section has primitive error correcting code to prevent the script halting if you run it for a second time.

Note 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 ("").

Note 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.

Note 4: For completeness, you may wish to find other instances of IsShortCut, for example at: HKCR\piffile and HKCR\WSHFile.

See more on removing shortcut arrows.

Your Bonus – Arrow.reg

Here is a .Reg File to remove shortcut arrows.  It is designed for XP and Windows Server 2003, but will work on Vista.

Copy this text into notepad.  Save as Arrow.reg.  Double click and merge with your XP registry.  Note the minus sign in: "IsShortCut"=-.  There are no speech marks around the (-).  If you tried "IsShortCut"="-", then you would not delete the value, but instead you would set its value to a minus sign. 

Important:  You need a blank line between Windows Registry editor and [HKEY…]

Windows Registry Editor Version 5.00
 

[HKEY_CLASSES_ROOT\lnkfile]
"IsShortCut"=-
"IsNotShortCut"=""

 

 

Reg File to return to the default situation, where shortcuts will display an arrow.  The script below, reverses the script above.

Windows Registry Editor Version 5.00
 

[HKEY_CLASSES_ROOT\lnkfile]
"IsShortCut"=""
"IsNotShortCut"=-

 

Summary of Remove Arrows on ShortcutHow to Remove Arrows on Shortcuts

Those arrows on shortcuts can be most annoying,  My methods remove the registry entry which controls these arrows.  The scripting techniques show you how to employ .RegWrite, .RegRead and especially, .RegDelete to control the appropriate registry values.

I have also included .Reg files, these are a quicker and more convenient method for achieving the same goal, removing the arrow from shortcuts.

See more about registry scripts

Registry  • Win Registry Hacks  •PowerShell Registry  • Ezine 8 Registry  • Ezines  •Tool Kit

Ezine 62 Registry  •Ezine 63 Registry  • Ezine 64 Write Registry  • Ezine 119 Registry shortcuts 

Ezine 121 CachedLogons  • Ezine 136 remove shortcut  •Ezine 137 Remove shortcut