# Builds QuadCastMuteSync, copies it to the install folder and runs it at every logon. # No admin rights needed: the task runs as the current user. # The default folder is outside AppData on purpose: when run from an MSIX-packaged app # (such as some terminals), writes to AppData are redirected and Task Scheduler can't see them. param([string]$InstallDir = (Join-Path $env:USERPROFILE 'QuadCastMuteSync')) $ErrorActionPreference = 'Stop' $TaskName = 'QuadCastMuteSync' $dest = $InstallDir $exe = Join-Path $dest 'QuadCastMuteSync.exe' & (Join-Path $PSScriptRoot 'build.ps1') Get-Process QuadCastMuteSync -ErrorAction SilentlyContinue | Stop-Process -Force New-Item -ItemType Directory -Force $dest | Out-Null Copy-Item (Join-Path $PSScriptRoot 'bin\QuadCastMuteSync.exe') $exe -Force $action = New-ScheduledTaskAction -Execute $exe -Argument 'run' $trigger = New-ScheduledTaskTrigger -AtLogOn -User "$env:USERDOMAIN\$env:USERNAME" $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries ` -ExecutionTimeLimit ([TimeSpan]::Zero) -MultipleInstances IgnoreNew ` -RestartCount 3 -RestartInterval (New-TimeSpan -Minutes 1) Register-ScheduledTask -TaskName $TaskName -Action $action -Trigger $trigger -Settings $settings ` -Description 'Mutes the HyperX QuadCast S at logon and keeps Windows mic mute in sync with it.' -Force | Out-Null Start-ScheduledTask -TaskName $TaskName Write-Host "Installed to $dest and registered logon task '$TaskName' (started now)."