27 lines
1,003 B
PowerShell
27 lines
1,003 B
PowerShell
# Put the original binkw32.dll back and relaunch the game.
|
|
# powershell -ExecutionPolicy Bypass -File undeploy.ps1 [-NoLaunch]
|
|
param(
|
|
[string]$GameDir = 'C:\SOTS',
|
|
[string]$Task = 'SOTS',
|
|
[switch]$NoLaunch
|
|
)
|
|
$ProgressPreference = 'SilentlyContinue'
|
|
$ErrorActionPreference = 'Stop'
|
|
|
|
$exe = 'Sword of the Stars'
|
|
$cur = Join-Path $GameDir 'binkw32.dll'
|
|
$real = Join-Path $GameDir 'binkw32_real.dll'
|
|
if (-not (Test-Path $real)) { throw "$real not found - nothing to restore" }
|
|
|
|
$p = Get-Process -Name $exe -ErrorAction SilentlyContinue
|
|
if ($p) { Write-Output "stopping $exe (pid $($p.Id))"; $p | Stop-Process -Force; Start-Sleep -Seconds 3 }
|
|
|
|
Move-Item $real $cur -Force
|
|
Write-Output "restored original binkw32.dll"
|
|
|
|
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" }
|
|
}
|