# Deploy the shim onto the game VM: stop the game, keep the original binkw32.dll as # binkw32_real.dll, drop in the proxy + config, relaunch. # powershell -ExecutionPolicy Bypass -File deploy.ps1 [-Dist Z:\shim\dist] [-NoLaunch] # If -Dist is on an unmapped drive, the share is mapped using -ShareUser/-SharePass # (or env RELAB_USER / RELAB_PASS). Credentials are never stored here. param( [string]$Dist = 'Z:\shim\dist', [string]$GameDir = 'C:\SOTS', [string]$Share = '\\192.168.10.138\re-lab', [string]$ShareUser = $env:RELAB_USER, [string]$SharePass = $env:RELAB_PASS, [string]$Task = 'SOTS', [switch]$NoLaunch ) $ProgressPreference = 'SilentlyContinue' $ErrorActionPreference = 'Stop' if (-not (Test-Path $Dist)) { $drive = $Dist.Substring(0, 2) if ($SharePass) { net use $drive $Share /user:$ShareUser $SharePass | Out-Null } if (-not (Test-Path $Dist)) { throw "cannot reach $Dist (share not mapped; pass -ShareUser/-SharePass)" } } $src = Join-Path $Dist 'binkw32.dll' if (-not (Test-Path $src)) { throw "no binkw32.dll in $Dist" } $exe = 'Sword of the Stars' $cur = Join-Path $GameDir 'binkw32.dll' $real = Join-Path $GameDir 'binkw32_real.dll' $p = Get-Process -Name $exe -ErrorAction SilentlyContinue if ($p) { Write-Output "stopping $exe (pid $($p.Id))"; $p | Stop-Process -Force; Start-Sleep -Seconds 3 } # First deploy: the file in place is the original. A proxy is recognisable by its forwarder strings. $isProxy = (Get-Content -Path $cur -Raw) -match 'binkw32_real\.' if (-not (Test-Path $real)) { if ($isProxy) { throw "$cur is already a proxy and $real is missing - restore the original first" } Copy-Item $cur $real Write-Output "backed up original -> $real" } Copy-Item $src $cur -Force $cfg = Join-Path $GameDir 'shim.cfg' if (-not (Test-Path $cfg)) { Copy-Item (Join-Path $Dist 'shim.cfg') $cfg } # keep operator edits $id = Join-Path $Dist 'BUILD_ID' if (Test-Path $id) { Write-Output "deployed build $(Get-Content $id)" } if (-not $NoLaunch) { schtasks /Run /TN $Task | Out-Null Start-Sleep -Seconds 5 $p = Get-Process -Name $exe -ErrorAction SilentlyContinue if ($p) { Write-Output "launched $exe (pid $($p.Id))" } else { Write-Warning "$exe not running 5 s after launch" } }