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")
|
$desktop = [System.Environment]::GetFolderPath("Desktop")
|
||||||
$bootDir = $ScriptDir
|
$bootDir = $ScriptDir
|
||||||
|
|
||||||
# 启动Bookworm 快捷方式
|
# 启动Bookworm 快捷方式 — 优先 pwsh (PS7),回退 powershell (PS5)
|
||||||
$lnkPath = Join-Path $desktop "Bookworm.lnk"
|
$lnkPath = Join-Path $desktop "Bookworm.lnk"
|
||||||
if (-not (Test-Path $lnkPath)) {
|
if (-not (Test-Path $lnkPath)) {
|
||||||
try {
|
try {
|
||||||
$shell = New-Object -ComObject WScript.Shell
|
$shell = New-Object -ComObject WScript.Shell
|
||||||
$shortcut = $shell.CreateShortcut($lnkPath)
|
$shortcut = $shell.CreateShortcut($lnkPath)
|
||||||
$batFile = Join-Path $bootDir "启动Bookworm.bat"
|
$scriptPath = Join-Path $bootDir "install.ps1"
|
||||||
if (Test-Path $batFile) {
|
$hasPwsh = [bool](Get-Command pwsh -ErrorAction SilentlyContinue)
|
||||||
$shortcut.TargetPath = $batFile
|
$psExe = if ($hasPwsh) { (Get-Command pwsh).Source } else { "powershell.exe" }
|
||||||
} else {
|
$shortcut.TargetPath = $psExe
|
||||||
$shortcut.TargetPath = "pwsh.exe"
|
$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.Arguments = "-ExecutionPolicy Bypass -File `"$(Join-Path $bootDir 'install.ps1')`" -StartOnly"
|
|
||||||
}
|
|
||||||
$shortcut.WorkingDirectory = $bootDir
|
$shortcut.WorkingDirectory = $bootDir
|
||||||
$shortcut.Description = "Bookworm Smart Assistant"
|
$shortcut.Description = "Bookworm Smart Assistant"
|
||||||
$shortcut.Save()
|
$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 {
|
} catch {
|
||||||
Write-Host " [!] 桌面快捷方式创建失败 (不影响使用)" -ForegroundColor Gray
|
Write-Host " [!] 桌面快捷方式创建失败 (不影响使用)" -ForegroundColor Gray
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user