$ErrorActionPreference = "Stop"

$here = Split-Path -Parent $MyInvocation.MyCommand.Path
$agentBat = Join-Path $here "run_print_agent.bat"
if (-not (Test-Path $agentBat)) {
    throw "run_print_agent.bat not found next to this script."
}

$startup = [Environment]::GetFolderPath("Startup")
$shortcutPath = Join-Path $startup "YarMenu Print Agent.lnk"
$wsh = New-Object -ComObject WScript.Shell
$shortcut = $wsh.CreateShortcut($shortcutPath)
$shortcut.TargetPath = $agentBat
$shortcut.WorkingDirectory = $here
$shortcut.WindowStyle = 7
$shortcut.Description = "YarMenu POS print station background agent"
$shortcut.Save()

Write-Host "Created startup shortcut:" -ForegroundColor Green
Write-Host $shortcutPath
Write-Host ""
Write-Host "Log in once in the print agent window, then you can close the main POS app."
