29 lines
880 B
PowerShell
29 lines
880 B
PowerShell
param(
|
|
[string]$ShortcutName = "Internal KVM Switch.lnk"
|
|
)
|
|
|
|
$ErrorActionPreference = "Stop"
|
|
|
|
$scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
|
|
$launcher = Join-Path $scriptDir "start_kvm_switch_background.vbs"
|
|
|
|
if (-not (Test-Path -LiteralPath $launcher)) {
|
|
throw "Launcher not found: $launcher"
|
|
}
|
|
|
|
$startupFolder = [Environment]::GetFolderPath("Startup")
|
|
$shortcutPath = Join-Path $startupFolder $ShortcutName
|
|
|
|
$wscript = New-Object -ComObject WScript.Shell
|
|
$shortcut = $wscript.CreateShortcut($shortcutPath)
|
|
$shortcut.TargetPath = "$env:WINDIR\System32\wscript.exe"
|
|
$shortcut.Arguments = """$launcher"""
|
|
$shortcut.WorkingDirectory = $scriptDir
|
|
$shortcut.IconLocation = "$env:WINDIR\System32\shell32.dll,220"
|
|
$shortcut.Save()
|
|
|
|
Write-Host "Autostart shortcut created/updated:"
|
|
Write-Host " $shortcutPath"
|
|
Write-Host "Target launcher:"
|
|
Write-Host " $launcher"
|