Skip to content

Commit

Permalink
fix(shortcuts): cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
he3als committed Sep 18, 2023
1 parent e9c7879 commit 5eb7072
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions src/playbook/Executables/SHORTCUTS.ps1
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
function New-Shortcut {
[CmdletBinding()]
param (
[Parameter(Mandatory = $True)][string]$ShortcutPath,
[Parameter(Mandatory = $True)][string]$Target,
[string]$Arguments,
[string]$IfExist,
[string]$Icon
[Parameter(Mandatory = $True)][ValidateNotNullOrEmpty()][string]$ShortcutPath,
[Parameter(Mandatory = $True)][ValidateNotNullOrEmpty()][string]$Target,
[ValidateNotNullOrEmpty()][string]$Arguments,
[ValidateNotNullOrEmpty()][string]$Icon,
[switch]$IfExist
)

if ($null -ne $IfExist -and $IfExist -ne "") {
if ($IfExist) {
if (-not (Test-Path -Path $ShortcutPath -PathType Leaf)) {
exit 1
return
}
}

$WshShell = New-Object -comObject WScript.Shell
$Shortcut = $WshShell.CreateShortcut($ShortcutPath)
$Shortcut.TargetPath = $Target
if ($Icon -ne $null -and $Icon -ne "") {$Shortcut.IconLocation = $Icon}
if ($null -ne $Arguments) { $Shortcut.Arguments = $Arguments }
if ($Icon) { $Shortcut.IconLocation = $Icon }
if ($Arguments) { $Shortcut.Arguments = $Arguments }
$Shortcut.Save()
}

Expand All @@ -35,7 +35,7 @@ New-Shortcut -ShortcutPath "$default Windows Services and Drivers.lnk" -Target "
New-Shortcut -ShortcutPath "$default Atlas Services and Drivers.lnk" -Target "$runAsTI" -Arguments "$env:windir\AtlasModules\Other\atlasServices.reg" -Icon "$env:windir\regedit.exe,1"

# Fix Windows Tools shortcut in Windows 11
$shortcutPath = "$env:APPDATA\Microsoft\Windows\Start Menu\Programs\Administrative Tools.lnk"
$newTargetPath = "explorer.exe"
$shortcutPath = "$env:appdata\Microsoft\Windows\Start Menu\Programs\Administrative Tools.lnk"
$newTargetPath = "$env:windir\explorer.exe"
$newArgs = "shell:::{D20EA4E1-3957-11d2-A40B-0C5020524153}"
New-Shortcut -ShortcutPath $shortcutPath -Target $newTargetPath -Arguments $newArgs -IfExist "True"
New-Shortcut -ShortcutPath $shortcutPath -Target $newTargetPath -Arguments $newArgs -IfExist

0 comments on commit 5eb7072

Please sign in to comment.