From 42e1944ccee401270e3751f6e524ae7b713063ef Mon Sep 17 00:00:00 2001 From: TermiNexus Date: Mon, 19 Oct 2026 20:30:40 +0800 Subject: [PATCH] =?UTF-8?q?fix(launcher):=20=E5=85=BC=E5=AE=B9=20-SRV=3D1?= =?UTF-8?q?=20=E7=AD=89=E5=8F=B7=E5=86=99=E6=B3=95=EF=BC=88=E6=94=B9?= =?UTF-8?q?=E7=94=A8=20args=20=E6=89=8B=E5=8A=A8=E8=A7=A3=E6=9E=90?= =?UTF-8?q?=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 3DTank/Start-LocalAndRelay.ps1 | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/3DTank/Start-LocalAndRelay.ps1 b/3DTank/Start-LocalAndRelay.ps1 index 224fddd..15d1f6f 100644 --- a/3DTank/Start-LocalAndRelay.ps1 +++ b/3DTank/Start-LocalAndRelay.ps1 @@ -31,7 +31,9 @@ // 强制走 c2(官方默认主服) .\Start-LocalAndRelay.ps1 -SRV 2 -OpenBrowser #> -[CmdletBinding()] +# 注意:这里刻意不用 [CmdletBinding()]。 +# PowerShell 原生不支持 -SRV=1 这种等号写法(会报 "parameter cannot be found"), +# 去掉 CmdletBinding 后,未绑定的 -SRV=1 会落进 $args,由下面手动解析兼容。 param( [int]$MirrorPort = 8080, [int]$RelayPort = 9091, @@ -51,6 +53,16 @@ param( ) $ErrorActionPreference = 'Stop' + +# ---------- 兼容 -SRV=1 / --SRV=1 等号写法 ---------- +# PowerShell 只认 -SRV 1 或 -SRV:1;等号形式会被当作未绑定参数落进 $args,这里手动识别 +foreach ($A in $args) { + if ($A -is [string] -and $A -match '^--?SRV=(.+)$') { + $SRV = [int]$Matches[1] + } +} +if ($SRV -notin 0, 1, 2) { throw "-SRV 只能是 0 / 1 / 2(收到: $SRV)" } + $Project = $PSScriptRoot # 3DTank/ $Tools = Join-Path $Project 'tools' $PacketDir = Join-Path $Project ("packets\{0}" -f $Label)