- Зачем: при повторном запуске через ярлык Kimi цеплялся к консоли pwsh и удерживал окно терминала открытым ради своих логов. - Что: ярлык переведён на скрытый VBS-запускатель (как у Claude Proxy); добавлен запасной путь %ProgramFiles%\Kimi для установки на всех пользователей. - Проверка: синтаксис скриптов проверен парсером PowerShell, tests/test_proxy_env_sync.py зелёный.
63 lines
2.0 KiB
PowerShell
63 lines
2.0 KiB
PowerShell
$ErrorActionPreference = 'Stop'
|
|
|
|
if (-not ($IsWindows -or $PSVersionTable.PSEdition -eq 'Desktop')) {
|
|
return
|
|
}
|
|
|
|
$LauncherPath = Join-Path $HOME '.local\bin\start-kimi-proxy.ps1'
|
|
$LauncherHostPath = Join-Path $HOME '.local\bin\start-kimi-proxy.vbs'
|
|
$ProgramsPath = [Environment]::GetFolderPath('Programs')
|
|
if ([string]::IsNullOrWhiteSpace($ProgramsPath)) {
|
|
Write-Warning 'Start Menu Programs folder was not found.'
|
|
return
|
|
}
|
|
|
|
$ShortcutPath = Join-Path $ProgramsPath 'Kimi Proxy.lnk'
|
|
$TargetPath = Join-Path $env:WINDIR 'System32\wscript.exe'
|
|
$Arguments = "//NoLogo `"$LauncherHostPath`""
|
|
$WorkingDirectory = $env:USERPROFILE
|
|
|
|
$KimiExecutable = @(
|
|
(Join-Path $env:LOCALAPPDATA 'Programs\Kimi\Kimi.exe'),
|
|
(Join-Path $env:ProgramFiles 'Kimi\Kimi.exe')
|
|
) | Where-Object { Test-Path -LiteralPath $_ } | Select-Object -First 1
|
|
if ($null -ne $KimiExecutable) {
|
|
$IconLocation = "$KimiExecutable,0"
|
|
} else {
|
|
$IconLocation = "$LauncherPath,0"
|
|
}
|
|
|
|
New-Item -ItemType Directory -Path (Split-Path -Parent $ShortcutPath) -Force | Out-Null
|
|
|
|
$Shell = New-Object -ComObject WScript.Shell
|
|
$Shortcut = $Shell.CreateShortcut($ShortcutPath)
|
|
|
|
$Changed = $false
|
|
if ($Shortcut.TargetPath -ne $TargetPath) {
|
|
$Shortcut.TargetPath = $TargetPath
|
|
$Changed = $true
|
|
}
|
|
if ($Shortcut.Arguments -ne $Arguments) {
|
|
$Shortcut.Arguments = $Arguments
|
|
$Changed = $true
|
|
}
|
|
if ($Shortcut.WorkingDirectory -ne $WorkingDirectory) {
|
|
$Shortcut.WorkingDirectory = $WorkingDirectory
|
|
$Changed = $true
|
|
}
|
|
if ($Shortcut.IconLocation -ne $IconLocation) {
|
|
$Shortcut.IconLocation = $IconLocation
|
|
$Changed = $true
|
|
}
|
|
if ($Shortcut.Description -ne 'Launch Kimi with hproxy.local proxy environment') {
|
|
$Shortcut.Description = 'Launch Kimi with hproxy.local proxy environment'
|
|
$Changed = $true
|
|
}
|
|
|
|
if ($Changed -or -not (Test-Path -LiteralPath $ShortcutPath)) {
|
|
$Shortcut.Save()
|
|
Write-Host "Kimi Proxy shortcut: updated $ShortcutPath"
|
|
} else {
|
|
Write-Host 'Kimi Proxy shortcut: already up to date.'
|
|
}
|