From e1e5f783c0511fb313ed7e02f46112e561510d04 Mon Sep 17 00:00:00 2001 From: tian <11429339@qq.com> Date: Mon, 20 Jul 2026 14:22:07 +0800 Subject: [PATCH] fix: resolve full exe path via Get-Command for Start-Process --- scripts/dev-env.ps1 | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/scripts/dev-env.ps1 b/scripts/dev-env.ps1 index b23fcb8..84b43f1 100644 --- a/scripts/dev-env.ps1 +++ b/scripts/dev-env.ps1 @@ -37,17 +37,21 @@ function Write-Banner { function Start-Detached { param([string]$Name, [string]$Exe, [string[]]$Args, [switch]$Visible) - $found = (Test-Path $Exe) -or (Get-Command $Exe -ErrorAction SilentlyContinue) - if (-not $found) { + $exePath = $Exe + if (-not (Test-Path $Exe)) { + $cmd = Get-Command $Exe -ErrorAction SilentlyContinue + if ($cmd) { $exePath = $cmd.Source } + } + if (-not $exePath -or -not (Test-Path $exePath)) { Write-Host " [SKIP] $Name : 未找到 $Exe" -ForegroundColor Yellow return $null } - Write-Host " [START] $Name" -ForegroundColor Green + Write-Host " [START] $Name ($exePath)" -ForegroundColor Green $style = if ($Visible) { "Normal" } else { "Minimized" } if ($Args -and $Args.Count -gt 0) { - $proc = Start-Process -FilePath $Exe -ArgumentList $Args -WindowStyle $style -PassThru + $proc = Start-Process -FilePath $exePath -ArgumentList $Args -WindowStyle $style -PassThru } else { - $proc = Start-Process -FilePath $Exe -WindowStyle $style -PassThru + $proc = Start-Process -FilePath $exePath -WindowStyle $style -PassThru } Start-Sleep -Milliseconds 500 return $proc