From 3f035c43d1a4018bf6b85f90f82af71a5c05f924 Mon Sep 17 00:00:00 2001 From: bookworm Date: Thu, 2 Apr 2026 20:15:10 +0800 Subject: [PATCH] fix: desktop shortcut targets pwsh.exe directly with NO_PROXY --- install.ps1 | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/install.ps1 b/install.ps1 index ed4e06c..5ac7ff6 100644 --- a/install.ps1 +++ b/install.ps1 @@ -159,23 +159,22 @@ function New-DesktopShortcuts { $desktop = [System.Environment]::GetFolderPath("Desktop") $bootDir = $ScriptDir - # 启动Bookworm 快捷方式 + # 启动Bookworm 快捷方式 — 优先 pwsh (PS7),回退 powershell (PS5) $lnkPath = Join-Path $desktop "Bookworm.lnk" if (-not (Test-Path $lnkPath)) { try { $shell = New-Object -ComObject WScript.Shell $shortcut = $shell.CreateShortcut($lnkPath) - $batFile = Join-Path $bootDir "启动Bookworm.bat" - if (Test-Path $batFile) { - $shortcut.TargetPath = $batFile - } else { - $shortcut.TargetPath = "pwsh.exe" - $shortcut.Arguments = "-ExecutionPolicy Bypass -File `"$(Join-Path $bootDir 'install.ps1')`" -StartOnly" - } + $scriptPath = Join-Path $bootDir "install.ps1" + $hasPwsh = [bool](Get-Command pwsh -ErrorAction SilentlyContinue) + $psExe = if ($hasPwsh) { (Get-Command pwsh).Source } else { "powershell.exe" } + $shortcut.TargetPath = $psExe + $shortcut.Arguments = "-NoLogo -ExecutionPolicy Bypass -Command `"Set-Item Env:NO_PROXY 'bww.letcareme.com,code.letcareme.com,letcareme.com,localhost,127.0.0.1'; & '$scriptPath' -StartOnly -AutoAccept`"" $shortcut.WorkingDirectory = $bootDir $shortcut.Description = "Bookworm Smart Assistant" $shortcut.Save() - Write-Host " [OK] 桌面快捷方式已创建: Bookworm" -ForegroundColor Green + $psVer = if ($hasPwsh) { "PowerShell 7" } else { "PowerShell 5.1" } + Write-Host " [OK] 桌面快捷方式已创建: Bookworm ($psVer)" -ForegroundColor Green } catch { Write-Host " [!] 桌面快捷方式创建失败 (不影响使用)" -ForegroundColor Gray }