Help Center

Follow

Deploy Desktop Shortcut with Custom Icon File

Purpose:
You wish to deploy a shortcut (URL, UNC path, local path) with a custom icon (.ico) file to all users.

Resolution:
Deploy a shortcut (URL/UNC//local path) using a script and a custom icon file (.ico).

Create (edit) the script

1. Create a .bat file called LinkMaker.bat that contains the following:

@echo off

set SCRIPT="%TEMP%\LinkMaker-%RANDOM%-%RANDOM%.vbs"

echo Set oWS = WScript.CreateObject("WScript.Shell") >> %SCRIPT%
echo sLinkFile = "%PUBLIC%\Desktop\MyLink.lnk" >> %SCRIPT%
echo Set oLink = oWS.CreateShortcut(sLinkFile) >> %SCRIPT%
echo oLink.TargetPath = "http://example.com" >> %SCRIPT%
echo oLink.IconLocation = "%PUBLIC%\documents\Example.ico" >> %SCRIPT%
: echo oLink.Arguments = ""  >> %SCRIPT%
: echo oLink.Description = "" >> %SCRIPT%
: echo oLink.HotKey = ""  >> %SCRIPT% 
: echo oLink.Arguments = ""  >> %SCRIPT%
: echo oLink.WindowStyle = ""  >> %SCRIPT%
: echo oLink.WorkingDirectory = ""  >> %SCRIPT%
echo oLink.Save >> %SCRIPT%

cscript /nologo %SCRIPT%
del %SCRIPT%

NOTES:

  • This creates a temporary vbs file in Windows\Temp with a random name. The vbs file is deleted at the end of the batch script.
  • The reason you want the files in %PUBLIC% is so that all users receive the link and the link can only be removed by a member of the Administrators group.
  • Uncomment (::) and add the appropriate information if desired.
  • Change the sLinkFile to the name of your .lnk file (keep the path).
  • Change the the oLink.TargetPath to the URL/UNC/local path.
  • Change the oLink.IconLocation to the path of the the .ico file on the target machine(s).

2. Save the file either locally or on a UNC share.

Create a package in PDQ Deploy

1. Create a New Package in PDQ Deploy. Name the package something meaningful.

2. Create a Copy step in that package (PDQ Deploy Pro or Enterprise mode required).

The source is going to be your icon file on the PDQ console machine and the target folder is going to be %public%\documents\ (this is the oLink.IconLocation in the script).

3. Create an Install step. Call the bat file from above.

4. Save and test the deployment.

EDIT March 30, 2017
One of our customer, Mike (thanks Mike!), wanted to be able to use Chrome to open the URL. This is what he and his 

@echo off
echo Set oWS = WScript.CreateObject("WScript.Shell") > CreateShortcut.vbs
echo sLinkFile = "%PUBLIC%\Desktop\Whatever.lnk" >> CreateShortcut.vbs
echo Set oLink = oWS.CreateShortcut(sLinkFile) >> CreateShortcut.vbs
echo oLink.TargetPath = "C:\Program Files\Google\Chrome\Application\chrome.exe" >> CreateShortcut.vbs
echo oLink.Arguments = "https://www.google.com/" >> CreateShortcut.vbs
echo oLink.IconLocation = "%PUBLIC%\documents\Whatever.ico" >> CreateShortcut.vbs
echo oLink.WindowStyle = "3" >> CreateShortcut.vbs
echo oLink.Save >> CreateShortcut.vbs

cscript /nologo CreateShortcut.vbs
del CreateShortcut.vbs

This has not been tested in our environment, so please test before deploying.

See Also:
Shortcut.exe Explained
Create URL desktop shortcut with customized .ico
How to run .reg, .bat .vbs and .ps1 files in PDQ Deploy
Copying and Deleting Shortcuts in PDQ Deploy

Was this article helpful?
1 out of 1 found this helpful
Have more questions? Submit a request

0 Comments

Article is closed for comments.
Powered by Zendesk