# Create Desktop + Start Menu shortcuts for Siraya Printer desktop manager.
param(
  [Parameter(Mandatory = $true)]
  [string]$TargetPath
)

$ErrorActionPreference = "Stop"

if (-not (Test-Path $TargetPath)) {
  throw "Target not found: $TargetPath"
}

$TargetPath = (Resolve-Path $TargetPath).Path
$WorkDir = Split-Path $TargetPath -Parent
$Name = "Siraya Printer"

function New-Shortcut {
  param(
    [string]$LinkPath,
    [string]$Target,
    [string]$WorkingDirectory,
    [string]$Description
  )
  $shell = New-Object -ComObject WScript.Shell
  $shortcut = $shell.CreateShortcut($LinkPath)
  $shortcut.TargetPath = $Target
  $shortcut.WorkingDirectory = $WorkingDirectory
  $shortcut.Description = $Description
  $shortcut.Save()
}

$desktop = [Environment]::GetFolderPath("Desktop")
$programs = [Environment]::GetFolderPath("Programs")
$group = Join-Path $programs "Siraya Printer"

New-Item -ItemType Directory -Path $group -Force | Out-Null

New-Shortcut `
  -LinkPath (Join-Path $desktop "$Name.lnk") `
  -Target $TargetPath `
  -WorkingDirectory $WorkDir `
  -Description "Siraya thermal printer manager"

New-Shortcut `
  -LinkPath (Join-Path $group "$Name.lnk") `
  -Target $TargetPath `
  -WorkingDirectory $WorkDir `
  -Description "Siraya thermal printer manager"

Write-Host "Desktop shortcuts created:"
Write-Host "  $(Join-Path $desktop "$Name.lnk")"
Write-Host "  $(Join-Path $group "$Name.lnk")"
