# Set-OpenTextAutoStart.ps1 - place WJ Shopfloor.lnk in the All Users # Startup folder so HostExplorer's "WJ Shopfloor" session launches at # every login. Idempotent: re-running is a no-op when the .lnk already # exists at the same path. # # Used by per-pc-type 09-Setup scripts for shopfloor types whose only # business app is OpenText (common, waxtrace, genspect, heattreat). # collections + nocollections do NOT auto-start OpenText - their techs # pick which apps via Configure-PC.ps1. # # Source .lnk is created by the OpenText preinstall (Setup-OpenText.ps1) # on the public desktop. If the .lnk is missing, log a warning and exit # 0 - imaging chain still continues; auto-start can be re-attempted on a # subsequent login by re-running this script. $ErrorActionPreference = 'Continue' $startupDir = 'C:\ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp' $publicDesktop = 'C:\Users\Public\Desktop' $candidates = @( Join-Path $publicDesktop 'WJ Shopfloor.lnk' Join-Path (Join-Path $publicDesktop 'Shopfloor Tools') 'WJ Shopfloor.lnk' ) $src = $candidates | Where-Object { Test-Path -LiteralPath $_ } | Select-Object -First 1 if (-not $src) { Write-Warning "WJ Shopfloor.lnk not found on public desktop - OpenText auto-start NOT configured." Write-Warning " Searched: $($candidates -join ' ; ')" Write-Warning " Setup-OpenText.ps1 should create it during preinstall - check OpenText install state." return } if (-not (Test-Path -LiteralPath $startupDir)) { New-Item -Path $startupDir -ItemType Directory -Force | Out-Null } $dst = Join-Path $startupDir 'WJ Shopfloor.lnk' try { Copy-Item -LiteralPath $src -Destination $dst -Force Write-Host "OpenText auto-start enabled: $dst (source: $src)" } catch { Write-Warning "Failed to copy WJ Shopfloor.lnk to startup: $_" }