Deploying Desktop Shortcuts
When deploying desktop shortcuts with PDQ Connect, you may encounter a browser limitation: uploading a .lnk file directly in a File Copy step causes the browser to resolve the shortcut and upload its target instead of the shortcut itself. This behavior can prevent shortcuts from being deployed as intended.
Below are two solutions to work around this issue.
Solution 1: Zip and Deploy the Shortcut
Since PDQ Connect automatically unzips archives attached to script steps, you can zip the shortcut file and then copy it to the desired location using PowerShell.
The following assumes that the desktop shortcut is being deployed to the public desktop folder. If you wish to deploy the shortcut to a specific user, either specify the users desktop directory as the $Destination variable, or set the Run mode on the file copy step to "Logged on user" and use "$env:userprofile\desktop" for the $Destination variable.
Steps:
- Zip the
.lnkfile you want to deploy. - Upload the zip file as an attachment to a Script step in your PDQ Connect package.
- Use the following PowerShell script to copy the shortcut to the public desktop:
# Modify this line to match the name of your shortcut inside the zip file
$Source = ".\YourShortcutName.lnk"
$Destination = "$env:public\desktop"
Copy-Item -Path $Source -Destination $Destination -ForceNote that the $Source in the script above should be the name of the shortcut (.lnk file), not the name of the zip file. PDQ Connect automatically extracts the zip file contents before running the script, so the zip file name is not needed.
The completed package should look similar to the image below.
Solution 2: Create the Shortcut Using PowerShell
Instead of deploying an existing shortcut, you can create one dynamically using PowerShell. This method is only recommended if you are unable to use Solution 1.
Example Script:
# Define shortcut path and target
$shortcutPath = "C:\Users\Public\Desktop\ShortcutName.lnk"
$shortcutTarget = "C:\Path\To\Your\Application.exe"
$shortcutIcon = "C:\Path\To\Icon.ico"
# Create a new Windows shortcut using PowerShell
$shell = New-Object -ComObject WScript.Shell
$shortcut = $shell.CreateShortcut($shortcutPath)
$shortcut.TargetPath = $shortcutTarget
$shortcut.IconLocation = $shortcutIcon
$shortcut.Save()
# Release COM object
[System.Runtime.InteropServices.Marshal]::ReleaseComObject($shell)Notes:
- Ensure the icon file exists on the target machine. A file copy step may be used for this purpose.
- Modify
$shortcutPath,$shortcutTarget, and$shortcutIconto match your environment.