windows: write steam_appid.txt before starting (the cause of the Steam error box); start the server window minimized

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
esefandClaude Opus 5.5 committed 2026-10-15 21:22:41 +03:00
1 parent 7d8aa4a029
commit d84d736846
4 files changed
+12 -8

No files matched your search

+8 -4
View File
@@ -334,11 +334,15 @@ function Start-CsServer($root) {
$y = $y -replace '(?m)^yb_difficulty ".*"', ('yb_difficulty "' + [int]$s.CS_BOT_DIFFICULTY + '"')
Write-TextFile $ycfg $y
$hargs = "-console -condebug -game cstrike -port $([int]$s.CS_PORT) +maxplayers $([int]$s.CS_MAXPLAYERS) +map $($s.CS_MAP) +log on"
# On the first start after an install, the server's Steam part sets itself up and the server
# stops with a "Fatal error: Unable to initialize Steam" box. A new start works, so that box
# gets the server closed and started again.
# A fresh install has no steam_appid.txt. hlds writes it while starting, but too late: Steam
# has already failed and the server sits on a "Fatal error: Unable to initialize Steam" box.
# 10 = Counter-Strike.
$appid = Join-Path $h 'steam_appid.txt'
if (-not (Test-Path -LiteralPath $appid) -or [IO.File]::ReadAllText($appid).Trim() -ne '10') { Write-TextFile $appid "10`r`n" }
# If that box still shows up, close the server and start it again. The window starts minimized
# so it doesn't take the keyboard away from whatever you're doing.
for ($try = 1; $try -le 3; $try++) {
$p = Start-Process -FilePath (Join-Path $h 'hlds.exe') -WorkingDirectory $h -ArgumentList $hargs -PassThru
$p = Start-Process -FilePath (Join-Path $h 'hlds.exe') -WorkingDirectory $h -ArgumentList $hargs -PassThru -WindowStyle Minimized
if (-not (Test-SteamFailure $p ([int]$s.CS_PORT))) { break }
Stop-Process -Id $p.Id -Force -ErrorAction SilentlyContinue
Start-Sleep -Seconds 2
+1 -1
View File
@@ -199,7 +199,7 @@ Write-Host " connect 127.0.0.1:$port (on this PC)" -ForegroundColor Gr
foreach ($ip in Get-LanIPv4) { Write-Host " connect ${ip}:$port (same house)" -ForegroundColor Green }
if ($s.CS_PUBLIC_ADDR) { Write-Host " connect $($s.CS_PUBLIC_ADDR) (friends over the internet)" -ForegroundColor Green }
Write-Host ''
Write-Host " The server runs in its own window. Close that window to stop it."
Write-Host " The server runs in its own window (minimized in the taskbar). Close that window to stop it."
Write-Host " Menu (start, stop, map, mode, bots, kill counter, ...): double-click cs.cmd in"
Write-Host " $Root"
if ($repo -ine $Root -and -not $Yes) { Start-Process explorer.exe -ArgumentList "`"$Root`"" }