$ErrorActionPreference = 'Stop' $ProxyHostName = 'hproxy.local' $ProxyPort = 12334 $HttpProxy = "http://${ProxyHostName}:${ProxyPort}" $ProxyBypassList = "${ProxyHostName};localhost;127.0.0.1;[::1];*.concept-software.ru;dementev.space;*.dementev.space" function Get-KimiApplication { $Candidates = @( (Join-Path $env:LOCALAPPDATA 'Programs\Kimi\Kimi.exe'), (Join-Path $env:ProgramFiles 'Kimi\Kimi.exe') ) foreach ($Executable in $Candidates) { if (Test-Path -LiteralPath $Executable) { return $Executable } } throw "Kimi Desktop не найден: проверены пути '$($Candidates -join "', '")'." } function Assert-KimiNotRunning { param( [Parameter(Mandatory)] [string]$Executable ) $RunningProcess = Get-CimInstance Win32_Process -ErrorAction SilentlyContinue | Where-Object { $_.ExecutablePath -eq $Executable } | Select-Object -First 1 if ($null -ne $RunningProcess) { throw 'Kimi уже запущен. Полностью закройте приложение и повторно откройте ярлык Kimi Proxy.' } } $KimiExecutable = Get-KimiApplication Assert-KimiNotRunning -Executable $KimiExecutable Start-Process -FilePath $KimiExecutable -ArgumentList @( "--proxy-server=${HttpProxy}", "--proxy-bypass-list=${ProxyBypassList}" )