Enhance autostart setup with a one-command installer and improve script logic for KVM switch launch
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
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"
|
||||
Reference in New Issue
Block a user