让 BLE 启动脚本读取用户环境变量

This commit is contained in:
Codex 2026-06-24 11:06:10 +08:00
parent 704f8a4e5d
commit 6468e91c7a

View File

@ -17,6 +17,16 @@ $pidFile = Join-Path $scriptDir "metrics-ble.pid"
$logFile = Join-Path $scriptDir "metrics-ble.log" $logFile = Join-Path $scriptDir "metrics-ble.log"
$errFile = Join-Path $scriptDir "metrics-ble.err.log" $errFile = Join-Path $scriptDir "metrics-ble.err.log"
foreach ($envName in @("ZHIPU_API_KEY", "ZHIPU_BASE_URL")) {
$processValue = [Environment]::GetEnvironmentVariable($envName, "Process")
if (-not $processValue) {
$userValue = [Environment]::GetEnvironmentVariable($envName, "User")
if ($userValue) {
[Environment]::SetEnvironmentVariable($envName, $userValue, "Process")
}
}
}
function Get-MetricsProcesses { function Get-MetricsProcesses {
Get-CimInstance Win32_Process -Filter "name='python.exe'" | Get-CimInstance Win32_Process -Filter "name='python.exe'" |
Where-Object { $_.CommandLine -and $_.CommandLine.Contains($pushScript) } Where-Object { $_.CommandLine -and $_.CommandLine.Contains($pushScript) }