#Issue with creating a shortcut where the targetpath still includes quotes:

3 messages · Page 1 of 1 (latest)

raw anvil
#

Current script:

$ShortcutPath = "$Home\Downloads\Extend Screen.lnk"
$IconLocation = "C:\Windows\System32\DisplaySwitch.exe"
$IconArrayIndex = 6
$WshShell = New-Object -comObject WScript.Shell
$Shortcut = $WshShell.CreateShortcut($ShortcutPath)
$path = "%windir%\System32\DisplaySwitch.exe /extend".Trim('"')
$Shortcut.TargetPath = $path
$Shortcut.IconLocation = "$IconLocation, $IconArrayIndex"
$Shortcut.Save()

Result:

kindred gate
#
$Shortcut.TargetPath = '%windir%\System32\DisplaySwitch.exe'
$Shortcut.Arguments = '/extend'

gotta separate path from args