techybiz
techybiz

Reputation: 1

Powershell: How to add shortcut to specific location on Desktop of Windows Server 2019

I am trying to add a shortcut to a specific location on the Desktop (Windows Server 2019).

I have the script to add the shortcut, but... it seems to just be auto-placed in the next vertical location.

I am wanting to create a few shortcuts in a "cluster", more toward the center of the Desktop.

Is this possible?

Below is my script that I use (In this case, it is IIS):

# Add IIS shortcut

$linkPath        = Join-Path ([Environment]::GetFolderPath('Desktop')) "IIS(Internet Information Services.lnk"
$targetPath      = Join-Path ([Environment]::GetFolderPath('Windows')) "\System32\inetsrv\InetMgr.exe"
$WshShell = New-Object -comObject WScript.Shell
$Shortcut = $WshShell.CreateShortcut($linkPath)
$Shortcut.TargetPath = "$targetPath"
$Shortcut.Save()

#This adds ADMIN privileges to the IIS shortcut

$bytes = [System.IO.File]::ReadAllBytes($linkPath)
$bytes[0x15] = $bytes[0x15] -bor 0x20 #set byte 21 (0x15) bit 6 (0x20) ON
[System.IO.File]::WriteAllBytes("$linkPath", $bytes)

write-host "IIS" -f 'cyan' -n;   write-host ([char]0xA0)

Any help is appreciated!

Thank you! Shane

I have Googled with all the terms I know, but they are not getting me to the solution I need... I only have the above script that I use for creating the shortcut itself... not sure where to begin to place the shortcut in a specific location on the Dekstop.

Upvotes: 0

Views: 55

Answers (0)

Related Questions