From ca00c159f0cd4e4ff54d9a832dfb0038dee04833 Mon Sep 17 00:00:00 2001 From: Christ Date: Thu, 13 Aug 2026 14:58:02 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20Windows=20=E6=9C=8D?= =?UTF-8?q?=E5=8A=A1=E5=91=BD=E4=BB=A4=E8=A1=8C=E6=A0=A1=E9=AA=8C=E8=AF=AF?= =?UTF-8?q?=E5=88=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/desktop-cd.yml | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/.github/workflows/desktop-cd.yml b/.github/workflows/desktop-cd.yml index 288ad00..a9564eb 100644 --- a/.github/workflows/desktop-cd.yml +++ b/.github/workflows/desktop-cd.yml @@ -296,10 +296,20 @@ jobs: $serviceConfig = Get-CimInstance -ClassName Win32_Service -Filter "Name='$serviceName'" -ErrorAction Stop if ($null -eq $serviceConfig) { throw 'Windows 服务注册后无法读取配置' } - if (-not $serviceConfig.PathName.Contains(('"{0}"' -f $serverPath)) -or - -not $serviceConfig.PathName.Contains('-service') -or - -not $serviceConfig.PathName.Contains(('-workdir "{0}"' -f $workDir)) -or - -not $serviceConfig.PathName.Contains(('-playwright-runtime-root "{0}"' -f $runtimeRoot))) { + # Win32_Service.PathName 可能会省略不含空格路径两侧的引号,比较前统一去掉引号。 + $actualServiceCommand = $serviceConfig.PathName.Replace('"', '') + $requiredServiceArguments = @( + $serverPath, + '-service', + "-workdir $workDir", + "-playwright-runtime-root $runtimeRoot" + ) + $invalidServiceArgument = $requiredServiceArguments | + Where-Object { + $actualServiceCommand.IndexOf($_, [StringComparison]::OrdinalIgnoreCase) -lt 0 + } | + Select-Object -First 1 + if ($null -ne $invalidServiceArgument) { throw "Windows 服务命令行不正确: $($serviceConfig.PathName)" } $delayedStart = Get-ItemPropertyValue `