48 lines
1.4 KiB
PowerShell
48 lines
1.4 KiB
PowerShell
[CmdletBinding(SupportsShouldProcess = $true)]
|
|
param(
|
|
[switch]$Remove,
|
|
[switch]$AllUsers
|
|
)
|
|
|
|
$ErrorActionPreference = "Stop"
|
|
|
|
$scriptDir = Split-Path -Parent $PSCommandPath
|
|
$vbsLauncher = Join-Path $scriptDir "start_streamdeck_hidden.vbs"
|
|
$shortcutName = "Custom Streamdeck Launcher.lnk"
|
|
|
|
if (-not (Test-Path $vbsLauncher)) {
|
|
throw "Launcher file not found: $vbsLauncher"
|
|
}
|
|
|
|
$startupFolder = if ($AllUsers) {
|
|
[Environment]::GetFolderPath("CommonStartup")
|
|
} else {
|
|
[Environment]::GetFolderPath("Startup")
|
|
}
|
|
|
|
$shortcutPath = Join-Path $startupFolder $shortcutName
|
|
|
|
if ($Remove) {
|
|
if (Test-Path $shortcutPath) {
|
|
if ($PSCmdlet.ShouldProcess($shortcutPath, "Remove startup shortcut")) {
|
|
Remove-Item -LiteralPath $shortcutPath -Force
|
|
Write-Host "Removed startup shortcut: $shortcutPath"
|
|
}
|
|
} else {
|
|
Write-Host "No startup shortcut found at: $shortcutPath"
|
|
}
|
|
return
|
|
}
|
|
|
|
if ($PSCmdlet.ShouldProcess($shortcutPath, "Create startup shortcut")) {
|
|
$shell = New-Object -ComObject WScript.Shell
|
|
$shortcut = $shell.CreateShortcut($shortcutPath)
|
|
$shortcut.TargetPath = "$env:SystemRoot\System32\wscript.exe"
|
|
$shortcut.Arguments = '"' + $vbsLauncher + '"'
|
|
$shortcut.WorkingDirectory = $scriptDir
|
|
$shortcut.Description = "Launch Custom Streamdeck backend and overlay hidden at sign-in."
|
|
$shortcut.Save()
|
|
|
|
Write-Host "Created startup shortcut: $shortcutPath"
|
|
}
|