AAC - Create a Public Desktop Shortcut for all users on Windows
Log In or Register to download the BES file, and more.

0 Votes

Description

Uses Powershell to create a public destop shortcut that works on most modern Windows systems (those supported by powershell)

When prompted you can provide an application full path or an URL:

URL example

https://bigfix.me

Application example:

C:\Program Files\Notepad++\notepad++.exe

When prompted for the name you can enter any valid filename (Warn: no checks are done)

Note: If you use the same name of an existing Public Desktop shortcut, it will be replaced. If you use the same name of a Private Desktop shortcut, two shortcuts will exist on User's desktop.


Property Details

ID25073
StatusBeta - Preliminary testing ready for more
TitleAAC - Create a Public Desktop Shortcut for all users on Windows
DomainBESC
CategoryUtility
SourceAndrea_Capasso@it.ibm.com
Source Release Date2/8/2018 12:00:00 AM
KeywordsPublic Desktop Shortcut
Is TaskTrue
Added by on 2/8/2018 9:22:34 AM
Last Modified by on 2/8/2018 9:22:34 AM
Counters 989 Views / 15 Downloads
User Rating 1 star 2 star 3 star 4 star 5 star * Average over 0 ratings. ** Log In or Register to add your rating.

Relevance

isWindows (Relevance 1172)
Used in 1107 fixlets and 524 analyses   * Results in a true/false
Show indented relevance
windows of operating system
Used in 1 fixlet   * Results in a true/false
Show indented relevance
exist keys "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell" whose (exists value "Path" of it) of native registry

Actions

Action 1 (default)

Action Link Click here to deploy this action.
Script Type BigFix Action Script
action parameter query "TargetURL" with description "Enter the URL or the ApplicationFullPath pointed by the Shortcut (for example: C:\Program Files\Notepad++\notepad++.exe )" and with default value "http://bigfix.me"
action parameter query "ShortcutName" with description "Enter the Name of the Desktop Shortcut" and with default value "Bigfix_Me"

// Retrieve Public Desktop location
parameter "DesktopPath"="{value "Common Desktop" of key "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" of native registry}"

// locate PowerShell .exe file
parameter "PowerShellexe"="{value "Path" of key "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell" of native registry}"

if {(parameter "TargetURL") as lowercase starts with "http"}
    parameter "Shortcut_ext"=".url"
elseif {(parameter "TargetURL") as lowercase ends with ".exe"}
    parameter "Shortcut_ext"=".lnk"
else
continue if {false}
endif
// build full path of Shortcut
parameter "ShortcutFile" = "{(parameter "DesktopPath") & "\" & (parameter "ShortcutName") & (parameter "Shortcut_ext")}"
// create PowerShell script
delete __createfile
createfile until __EOF__
$Target = "{parameter "TargetURL"}"
# $ShortcutFile = (Get-ItemProperty -Path 'HKLM:\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders').'Common Desktop'
# $ShortcutFile = $ShortcutFile + "{"\" & (parameter "ShortcutName") & ".url" }"
$ShortcutFile = "{parameter "ShortcutFile"}"
$WScriptShell = New-Object -ComObject WScript.Shell
$Shortcut = $WScriptShell.CreateShortcut($ShortcutFile)
$Shortcut.TargetPath = $Target
$Shortcut.Save()
__EOF__

delete "shortcut.ps1"
copy __createfile "shortcut.ps1"

// just in case, remove the old shortcut should it exists
delete "{parameter "ShortcutFile"}"
// execute PS script and check we did it or fail
waithidden "{parameter "PowerShellexe"}" -ExecutionPolicy Bypass ".\shortcut.ps1"
continue if {exit code of action = 0 }
continue if {exists file (parameter "ShortcutFile")}
Success Criteria

This action will be considered successful when the applicability relevance evaluates to false.


Sharing

Social Media:
Share this page on Yammer

Comments

Log In or Register to leave comments!
yusufabagay -
it's working thank you
jgstew -
related: https://bigfix.me/fixlet/details/741