All about Software
 Latest Software articles
All Software articles

Newsletters


  • Ask your question about IT issues
  • Post

Partners

The Games selection

violent : More Mindless Violence Basic shooting game, but still so powerful! Use the mouse to take aim and shoot at the little beasties before they get to you. Use Space to reload....
action : Yoyo the Star Yoyo is a young girl who recently graduated and dreams to become a movie star (don't we all). You'll have to guide her on the path to stardom,...
Ads

Sponsored links

Two Visual Basic Scripts

Previous Next
7:38 AM - 03/29/2007 by Guy Thomas

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.

These scripts are designed for XP and Windows 2003. While they will work on Vista, as noted above, they produce ugly side-effects on icons in the Favorites folder.

Example 1: Basic Script To Remove The Arrow On Shortcuts

Instructions
  • 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.
  • Copy and paste the script below into notepad, or get a script editor such as OnScript.
  • Save the file with .vbs extension e.g. NoArrowEg1.vbs
  • Double click your VBScript, then 'OK' the message box.
  • To help you understand what is happening in the Registry, I recommend that you launch regedit and navigate to the section specified by strRoot.
  • 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 in XP
' and Windows 2003.
' 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
  1. Check how VBScript creates the objShell object, then trace how .RegDelete performs its work on the Registry.
  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.
  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.
Talkback
Comments are closed on this page.

Sponsored links