Bize Ulaşın / Contact Us

Create Desktop Shortcut with Script

11 / 11 / 2011 by SCCM / Configuration Manager, Scripting Yorum yok / No Comments

Hi all

Today, I have received an application to deploy with SMS Server 2003, I had to create a MSI Package and some scripts to make that application installation most user friendly, actualy something doesn’t need user interaction. So I have needed a script that can find logged user profile folder and create a desktop shortcut to the configuration file in user profile folder.

I have found an article about how to create desktop shortcuts at Technet , it is detailed enough to understand how to do it,

Technet Script :


As you see above script creates WshShortcut object by calling CreateOBject, than it defines Desktop folder path with strDesktopFolder by AllUsersDesktop value. But we will change this script to locate and crete a desktop shortcut of a file that unique for every user.

First of all we need to find logged users profile path, to do this we will get USERSPROFILE value from Windows Environment Settings by adding this line

UsersProfile = objShell.ExpandEnvironmentStrings(“%USERPROFILE%”)

now we know logged users profile path has defined in UsersProfile (e.g. C:\Documents and Settings\OShener)

*Tip : You can get another Windows Environment variables values by using objShell.ExpandEnvironmentStrings by changing variable name in (%%) , you can check your existing environment variables by running set command in command promt too.

So where is our user specific target file for shortcut ? Let assume it is located in DW folder and the DW folder is in the the logged users profile folder. Now we are going to define a variable to fix the target file path with this line:

objShortCut.TargetPath = UsersProfile & “\DW\DW.conf”

and to find and define logged users desktop path to a variable we add this line to the script too

strDesktopFolder = objShell.SpecialFolders(“Desktop”)

and we have to define the Desktop Shortcut location before create it

Set objShortCut = objShell.CreateShortcut(strDesktopFolder & “\DWConf.lnk”)

Ok, let tidy up the script and see what we have now ?

If you wish you can add different properties to your shortcut too, like Windows HotKey, Description, Working Folder, only thing you need to do that add ObjShortcut properties as : objShortCut.HotKey = “Ctrl+Shift+D” and refer to the link :


Leave a Reply

Your email address will not be published. Required fields are marked *

Kontrol / Control * Time limit is exhausted. Please reload CAPTCHA.