Skip to content

Client Commands

Yukino Song edited this page Jan 26, 2025 · 5 revisions

Commands that are executed when a client connects or disconnects.

Basically the same as app's do and undo command, but run when the specific client connect/disconnects. You can use this to execute specific tasks like suspending the current running game on disconnect and resume on connect back.

If you don't want the commands to execute on specific app, go to the app's settings and disable Allow client prepare commands.

Checkout Auto Pause/Resume Games to configure auto game suspends.


Here's another example to put your computer to standby when the client disconnects:

First, save the following script to standby.ps1

Add-Type -AssemblyName System.Windows.Forms

# Function to detect keypress during the wait
function Wait-And-Abort-On-Keypress {
    $timeout = 2  # Timeout in seconds
    Write-Host "Press any key to abort in $timeout seconds..." -ForegroundColor Yellow
    $startTime = Get-Date
    while ((Get-Date) -lt $startTime.AddSeconds($timeout)) {
        if ([System.Console]::KeyAvailable) {
            Write-Host "Key press detected. Aborting script."
            return $true
        }
        Start-Sleep -Milliseconds 100
    }
    return $false
}

# Wait for 2 seconds and check for keypress
if (Wait-And-Abort-On-Keypress) {
    exit
}

# Put the system to suspend state
[System.Windows.Forms.Application]::SetSuspendState([System.Windows.Forms.PowerState]::Suspend, $false, $false)

Then add the following line to disconnect command of your client:

powershell -ExecutionPolicy Bypass -File "D:\scripts\standby.ps1"

The new command will take effect when your client reconnects.

Clone this wiki locally