fix: desktop shortcut targets pwsh.exe directly with NO_PROXY
This commit is contained in:
parent
1d79d815dc
commit
3f035c43d1
17
install.ps1
17
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
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user