Creating, modifying, and deleting shortcuts the easy way

2010-05-05 08:02:00 +0000

A colleague recently asked me for help with a VBScript she was working with. The purpose of the script was to change the target of a shortcut that was sitting on the Desktop of a number of computers in her environment. Her intent was to set this script to run at startup or logon and edit the shortcut to point to a new target.

Things got a little more complicated when she discovered that the shortcut might be on the userʼs personal desktop, on the All Users desktop (this was Windows XP), or even in the Default User desktop. The standard for setting this shortcut changed over time, so now her environment wasnʼt homogeneous.

And you thought only milk could be homogeneous?

Two years ago, I would have merrily worked out a script without giving this a second thought. But today, there is a better way. You donʼt need to pull out your hair debugging a script to take care of this. Enter Group Policy Preferences.

I am often surprised when I find someone who doesnʼt know about Group Policy Preferences, because they have been around since Windows Vista and Server 2008. The most attractive description I can give of Group Policy Preferences is that they will make 99% of your startup/shutdown and logon/logoff scripts obsolete. But mapped drives, networked printers, and desktop shortcuts are only the beginning. You can set just about anything in the registry, too.

I say “just about” anything because I havenʼt tried to set everything in the registry yet. But everything I have tried has worked.

Now, enough marketing. Letʼs get down to business: creating, modifying, and deleting shortcuts using Group Policy Preferences.

In Group Policy Management Editor, browse down to Computer Configuration\Preferences\Windows Settings\Shortcuts.

Group Policy Preferences: Shortcuts

Right-click on Shortcuts and choose New → Shortcut. Set the Action to Replace. Replace is a good choice for Action because it will create a shortcut if it doesnʼt already exist, it will overwrite a shortcut that already exists, and it will give you the option of removing the shortcut when the computer or user falls out of the scope of the Group Policy Object.

If you are trying to overwrite an existing shortcut in your environment, then Name and Location need to match the name and location of the existing shortcut. In this example, we will set Name to site-licensed on Austin Disk and set Location to All Users Desktop using the drop-down list.

If you are dealing with shortcuts on individual usersʼ desktops, you should configure the shortcut in the User Configuration section and set Location to Desktop using the drop-down list.

Set Target type to the type of thing the shortcut will point to. For network shares, choose File System Object.

Set Target path to the target of the shortcut. In this example, I want the shortcut to point to a network share at \\austin.utexas.edu\disk\site-licensed.

If you set Target type to URL, this field is called Target URL. If you set Target type to Shell Object, this field is called Target object.

If you want, you can choose an icon for the shortcut by clicking on the […] button next to Icon file path.

Group Policy Preferences: Shortcuts Example

Save the Shortcut and link the Group Policy Object. When Group Policy updates on your clients, behold a shortcut appear (or be replaced) on the desktop!

For more details on what you can do with Shortcuts in Group Policy Preferences, click the Help button while editing a Shortcut item.