Important Notice: On February 29th, this community was put into read-only mode. All existing posts will remain but customers are unable to add new posts or comment on existing. Please feel to join our Community Discord for any questions and discussions.

Copy shortcut and custom icon

As requested from today's (9/8/2016) webcast on copying/deleting files and shortcuts.  Here's a custom package I threw together to create shortcuts to an internal website with a custom icon.

Step 1 is a file copy step.  
Copies "Custom.ico" from a folder on the PDQDeploy server to "%Public%\Documents" on client computer.

Step 2 - Run batch file that creates shortcut (I found this script online somewhere and modified):

@echo off

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

echo Set oWS = WScript.CreateObject("WScript.Shell") >> %SCRIPT%
echo sLinkFile = "%PUBLIC%\Desktop\Internal WebSite App.lnk" >> %SCRIPT%
echo Set oLink = oWS.CreateShortcut(sLinkFile) >> %SCRIPT%
echo oLink.TargetPath = "http://InternalSite/AppName" >> %SCRIPT%
echo oLink.IconLocation = "%PUBLIC%\documents\Custom.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%

To recap...2 steps were needed:
Copy File step to get the .ico file on the PC's
A command step to run the batch file

This worked for me, not sure if anyone else has something easier.



Date Votes
  • I just have a folder full of shortcut files that I copy to the Public Desktop with the File Copy step. 1 package per shortcut.

  • There are few ways to go about this, easiest would be what Colby already suggested - having shortcuts lying ins a share and you just copy them using File Copy step in PDQ to %public%\desktop

    Another method I use to create shortcuts is powershell. By copying file locally somewhere and then creating shortcut to it with PS:

    # Variable defines, EDIT HERE

    # Exit early if alraedy installed
    If (Test-Path $InstallPath) {
    exit 0

    New-Item $InstallPath -Type Directory
    Copy-Item -Path ($SharePath + "\*.*") -Destination $InstallPath -Recurse

    # Create a Shortcut
    $TargetFile = ($InstallPath + "\file.exe") # EDIT HERE
    $ShortcutFile = "$env:Public\Desktop\My Shortcut.lnk" #EDIT HERE
    $WScriptShell = New-Object -ComObject WScript.Shell
    $Shortcut = $WScriptShell.CreateShortcut($ShortcutFile)
    $Shortcut.TargetPath = $TargetFile

    One more method ofc is to create shortcut yourself again and deploy it to user's desktops via GPO.