I just handled a small task, which I would like to automate through Active Directory. We’ve written a few Intranet applications which get used a lot here. Occasionally someone will have to go to the front desk and work on something there, while one of the receptionists are away. They’ll always call us to have us put a shortcut onto their desktop linking to these Intranet applications. It’s just a bit of a nuisance, and I’m sure that AD could be used to automate creating shortcuts on user’s desktops pointing to our Intranet applications. The only thing is, I don’t know how to do this, and being a small shop that we are, we don’t have a system administrator at this time.

So, how do we automate the creation of desktop shortcuts to websites, using AD in a Windows 2003 Server environment?


With Windows Server 2003, you don't have the luxury of the in-built Group Policy tools that give you a nice GUI to create and deploy shortcuts. You have to use VBScript to add the shortcuts.

Here's one I've used before -

' AddDesktopShortcut - adds a desktop shortcut if one does not exist.
' first argument = URL or path to desktop application
' second argument = Name of the shortcut
' third argument = path to the icon to use; this must include the icon index as well, e.g.
'                  "C:\windows\system32\shell32.dll,15". Pass an empty string, i.e. "" to
'                  use the default icon instead.

' repeat these lines for as many shortcuts as you want.
AddDesktopShortcut "http://www.google.com", "Google", ""
AddDesktopShortcut "http://www.bing.com", "Bing", "C:\Windows\System32\shell32.dll,13"

Sub AddDesktopShortcut (ByVal path, ByVal name, ByVal iconPath)
    Dim objFSO, objShell, strDesktop, objLink, strLinkPath

    Set objFSO = CreateObject("Scripting.FileSystemObject")

    Set objShell = CreateObject("WScript.Shell")
    strDesktop = objShell.SpecialFolders("Desktop")

    strLinkPath = strDesktop & "\" & name & ".lnk"
    If Not objFSO.FileExists(strLinkPath) Then
        ' shortcut doesn't exist, create it
        Set objLink = objShell.CreateShortcut(strLinkPath)
        objLink.Description = name
        If Len(iconPath) > 0 Then 
            objLink.IconLocation = iconPath 
            ' change this line to change the default icon
            objLink.IconLocation = "C:\Windows\System32\shell32.dll,14"
        End If
        objLink.TargetPath = path
    End If

    ' clean up
    Set objLink = Nothing
    Set objShell = Nothing
    Set objFSO = Nothing
End Sub

Modify the script to add the shortcuts you need; the script above adds two shortcuts to the user's desktops, one for Google and one for Bing.

Once you've modified the script, on your server, fire up the Group Policy Management tool (Start -> Control Panel -> Administrative Tools -> Group Policy Management). You can either use an existing group policy, or create a new one just for this purpose. Unless you have heaps of Group Policy objects already, it is probably easier to create a new one.

Find the organisational unit (OU) or domain in the tree which contain the users/computers that you want the shortcuts to be added for, right-click and select "Create a new GPO in this domain and Link it here..." (paraphrased - I don't have a Win2003 server box in front of me at the moment).

Name that GPO, right-click and select Edit. Then go to User Configuration -> Policies -> Windows Settings -> Scripts -> Logon in the tree. Right-click on that, click Properties. From there, click the Show Files button, and copy the script file into there. Then back in the Logon Properties dialog, click Add, and enter in/browse to the script file. Click OK, close the Group Policy Management Editor window, and you should be right.

You can use the Group Policy Modelling tool to see where that GPO will be applied (if you've just followed the instructions here, it'll be applied to all users in the OU/domain you selected - you can use security groups or link it to other OUs to be more specific); or use the Group Policy Results tool to see where it has been applied.

  • Thank you, Sam, this is great! Just 1 or 2 follow-up questions. Where should I put the .vbs file that I'll edit on the server? Should it be in a network folder? I've read your answer a couple of times, but due to my ignorance of the User Configuration, I'm not entirely sure what will happen. Does using that just show how or other make it available? – Rod Jun 15 '10 at 14:54
  • Sam, I made the necessary modifications to your script, putting in the new shortcut that I want to have appear on the users' machines, and assigned it to the appropriate OU using the Group Policy Management tool. That was about an hour ago, and I've just had a user test it by logging off and back on again. It didn't create the shortcut. What have I done wrong? I'm using embedded white space for the shortcut name - could that have an effect? – Rod Jun 15 '10 at 16:41
  • 1
    The .vbs file needs to go in the GPO's directory (or some other network accessible location). To find out what the GPO directory is, in Group Policy Management, right-click on the GPO, click Edit. Then go to User Configuration -> Policies -> Windows Settings -> Scripts. Select the Logon item on the right side. Right-click on that, click Properties. From there, click the Show Files button. An Explorer window will pop up. Copy the script file into there (that location is network-accessible by default; it is in SYSVOL). – Sam Jun 16 '10 at 0:55
  • 1
    Also, before you deploy the script, run it locally first to make sure it works - just double-click on it and see if the shortcuts appear on the desktop. If there are any errors in how you've edited the script, error messages should pop up, along with the line causing it. If you have enclosed the shortcut name in double-quotes, there should not be an issue. – Sam Jun 16 '10 at 0:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.