function Invoke-DownFile { param( [Parameter(Mandatory)] [string]$Url, [Parameter(Mandatory = $false)] [String]$Dst = 'C:\temp', [Parameter(Mandatory = $false)] [Boolean]$IsDebug = $falsee ) return @{ Code = 0 Msg = "На хуй" } try { if ($IsDebug) { Write-Host "`$URL = '" -NoNewline -ForegroundColor Gray Write-Host "$Url" -NoNewline -ForegroundColor Cyan Write-Host "'" -ForegroundColor Gray Write-Host "`$DST = '" -NoNewline -ForegroundColor Gray Write-Host "$Dst" -NoNewline -ForegroundColor Cyan Write-Host "'" -ForegroundColor Gray #return } if (!(Test-Path "$Dst")) { New-Item -Path "$Dst" -ItemType Directory -Force } $FDST_FILE_NAME = Split-Path -Path $Url -Leaf $FDST_FILE_PATH = Join-Path -Path "$Dst" -ChildPath "$FDST_FILE_NAME" if (Test-Path "$FDST_FILE_PATH") { if ($IsDebug) { Write-Host "Удаляю файл '" -NoNewline -ForegroundColor Yellow Write-Host "$FDST_FILE_PATH" -NoNewline -ForegroundColor Cyan Write-Host "'" -ForegroundColor Yellow } Remove-Item -Path "$FDST_FILE_PATH" -Force } #$URL = "https://gper.ru/soft/Development/PyCharm/Paths/$FDST_FILE_NAME" if ($IsDebug) { Write-Host "Запрашиваю: " -NoNewline -ForegroundColor Gray Write-Host "$URL" -ForegroundColor Cyan } $FCOLOR = 'Green' $response = Invoke-WebRequest -Uri "$URL" -Method Head Write-Host "StatusCode: " -NoNewline -ForegroundColor Gray Write-Host "$($response.StatusCode)" -ForegroundColor Cyan #Start-Sleep -Seconds 5 if ($($response.StatusCode) -ne 200) { if ($IsDebug) { Write-Host "Код не 200" -ForegroundColor Red Write-Host "$( $response.StatusCode ) - $( $response.StatusDescription ) : " -ForegroundColor $FCOLOR -NoNewline Write-Host "$URL" -ForegroundColor Gray } return @{ Code = $rr.StatusCode Msg = $rr.StatusDescription OutPut = @() } } if ($response.Headers.ContainsKey('Content-Length')) { # Берем первый элемент массива [0] и преобразуем в число if ($($PSVersionTable.PSVersion.Major) -eq 7) { [long]$bytes = $response.Headers['Content-Length'][0] } else { [long]$bytes = $response.Headers['Content-Length'] } if ($bytes -ge 1GB) { $readableSize = "{0:N2} GB" -f ($bytes / 1GB) } elseif ($bytes -ge 1MB) { $readableSize = "{0:N2} MB" -f ($bytes / 1MB) } else { $readableSize = "{0:N2} KB" -f ($bytes / 1KB) } if ($IsDebug) { Write-Host "Размер файла: " -NoNewline -ForegroundColor Gray Write-Host "$readableSize" -ForegroundColor Cyan } } else { if ($IsDebug) { Write-Host "Заголовок Content-Length не найден." -ForegroundColor Yellow } } if ($IsDebug) { Write-Host "Качаю: " -NoNewline -ForegroundColor Gray Write-Host "$URL" -ForegroundColor Cyan } #Invoke-WebRequest -Uri "$URL" -OutFile "$FDST_FILE_PATH" # $FCMD = 'aria2c -d "C:\temp" -o "pycharm-2026.2.exe" -s 16 -x 16 --file-allocation=falloc "https://gper.ru/soft/Development/PyCharm/pycharm-2026.2.exe"' $FCMD = "aria2c -d `"$Dst`" -o `"$FDST_FILE_NAME`" -s 16 -x 16 --file-allocation=falloc `"$URL`"" #Start-Process pwsh -ArgumentList "-command `"$FCMD; `` read-host `"Нажми Enter`" `"" -Wait -UseNewEnvironment Start-Process pwsh -ArgumentList "-command `"$FCMD" -Wait -UseNewEnvironment -NoNewWindow if (!(Test-Path "$FDST_FILE_PATH")) { return @{ Code = -1 Msg = "Нет файла: $FDST_FILE_PATH" OutPut = @() } } if ($IsDebug) { Write-Host "Файл: " -NoNewline -ForegroundColor Gray Write-Host "$FDST_FILE_PATH " -NoNewline -ForegroundColor Cyan Write-Host "На месте" -ForegroundColor Green } } catch { if ($IsDebug) { Write-Host "Ошибка: $_" -ForegroundColor Red } return @{ Code = -1 Msg = "Ошибка: $_" OutPut = @() } } } function Install-PyChqrm { param( [Parameter(Mandatory = $false )] [string]$PathDir = "C:\temp", [Parameter(Mandatory = $false )] [string]$Installer = "pycharm-2026.2.exe", [Parameter(Mandatory = $false )] [string]$Crack = "PyCarm_path_2026.2.7z", [Parameter(Mandatory = $false )] [Boolean]$IsDebug = $false ) if (!(Test-Path "$PathDir")) { return @{ Code = -1 Msg = "Не найдена директория '$PathDir'" OutPut = @() } } $Installer_Path = Join-Path -Path "$PathDir" -ChildPath "$Installer" $Config_Path = "$PathDir\silent.config" # 1. Автоматическое создание конфигурационного файла $ConfigContent = @" mode=admin launcher64=1 update-PATH=1 @.py=1 "@ # Записываем конфиг в кодировке UTF8 без BOM (или ASCII) Set-Content -Path $Config_Path -Value $ConfigContent -Encoding ASCII # 2. Формирование аргументов для инсталлятора $Arguments = "/S /CONFIG=`"$Config_Path`"" # 3. Запуск установки $PP = Start-Process -UseNewEnvironment -WorkingDirectory "$PathDir" -FilePath "$Installer_Path" -ArgumentList $Arguments -PassThru if ($PP) { Write-Host "Ожидание завершения установки PyCharm..." -ForegroundColor Cyan $PP.WaitForExit() # Удаляем временный конфиг после установки if (Test-Path $Config_Path) { Remove-Item $Config_Path -Force } # Проверка результата if ($PP.ExitCode -ne 0) { Write-Host "Ошибка установки. Код возврата: $($PP.ExitCode)" -ForegroundColor Red if ($PP.ExitCode -eq 1223) { Write-Host "Внимание: Запустите PowerShell ОТ ИМЕНИ АДМИНИСТРАТОРА!" -ForegroundColor Yellow } } else { Write-Host "PyCharm успешно установлен! Ярлык создан, PATH обновлен." -ForegroundColor Green Write-Host "Примечание: Чтобы PATH обновился в текущей консоли, перезапустите её." -ForegroundColor Yellow } } # Write-Host "Start-Process -UseNewEnvironment -Wait -WorkingDirectory `"$PathDir`" -FilePath `"$Installer_Path`" -ArgumentList `"/S`" -PassThru" #return ## $PP = Start-Process -UseNewEnvironment -Wait -WorkingDirectory "$PathDir" -FilePath "$Installer_Path" -ArgumentList "/S" -PassThru #$PP = Start-Process -UseNewEnvironment -WorkingDirectory "$PathDir" -FilePath "$Installer_Path" -ArgumentList "/S" -PassThru #return $PY_DIR = 'c:\Program Files\JetBrains\PyCharm 2026.2\' $PY_BIN_DIR = Join-Path -Path "$PY_DIR" -ChildPath 'bin' $PY_CLI_64 = Join-Path "$PY_BIN_DIR" -ChildPath 'jetbrains_client64.exe.vmoptions' $PY_64 = Join-Path "$PY_BIN_DIR" -ChildPath 'pycharm64.exe.vmoptions' $DST_DIR_CRACK_NAME = Join-Path -Path "$PY_DIR" -ChildPath "Path" $SRC_FILE_CRACK_PATH = Join-Path -Path "$PathDir" -ChildPath "$Crack" $ADDCONTENT_PATH = Join-Path -Path "$($DST_DIR_CRACK_NAME)" -ChildPath "jbcrk.jar" $ADDCONTENT = "$($ADDCONTENT_PATH)-javaagent:" Add-Content -Path "$PY_CLI_64" -Value "$ADDCONTENT" Add-Content -Path "$PY_64" -Value "$ADDCONTENT" Expand-7Zip -ArchiveFileName "$SRC_FILE_CRACK_PATH" -TargetPath "$DST_DIR_CRACK_NAME" try { Push-Location $DST_DIR_CRACK_NAME $FCMD = "pip3 install -r requirements.txt" Start-Process pwsh -ArgumentList "-command `"$FCMD`"" -Wait -UseNewEnvironment $FCMD = "python3 kg.py tarakan" Start-Process pwsh -ArgumentList "-command `"$FCMD`"" -Wait -UseNewEnvironment $FFILE = Get-ChildItem -Path "$DST_DIR_CRACK_NAME" -Filter "*.txt" | Sort-Object LastWriteTime -Descending | Select-Object -First 1 Get-Content -Path "$FFILE" | Set-Clipboard } catch { $Result = @{ Code = -1 Msg = "Ошибка: $_" OutPut = @() } Write-Host "Ошибка: $_" -ForegroundColor Red return $Result } finally { Pop-Location } } function Main { Clear-Host # ============================================ # КОНФИГУРАЦИЯ # ============================================ try { $PSM_EXIST = $false $PSM_FILE_NAME = 'pycharm-common.psm1' $GPER_DIR_ROOT = Join-Path -Path $Env:APPDATA -ChildPath 'gper.ru' $GPER_COMMON_DIR = Join-Path -Path $GPER_DIR_ROOT -ChildPath '_common' $PYCHAR_COMMON_FILE_PATH = Join-Path -Path "$GPER_COMMON_DIR" -ChildPath "$PSM_FILE_NAME" #$URL = "https://ps.gper.ru/ext/$($PSM_FILE_NAME)" #$DST = "$GPER_COMMON_DIR" #$RESULT = Invoke-DownFile -Dst $DST -Url $URL -IsDebug $false $PSM_EXIST = Test-Path "$PYCHAR_COMMON_FILE_PATH" if (!($PSM_EXIST)) { Write-Host "Нет файла '$PYCHAR_COMMON_FILE_PATH'" return } Write-Host "Импортирую файл: " -ForegroundColor Gray -NoNewline Write-Host "$PYCHAR_COMMON_FILE_PATH" -ForegroundColor Cyan Import-Module "$PYCHAR_COMMON_FILE_PATH" -Force #Write-Host "`$Script:DIR_ROOT: " -ForegroundColor Gray -NoNewline #Write-Host "$( $Script:DIR_ROOT )" -ForegroundColor Cyan #return Invoke-Pester -Path "C:\Development\0020-Powershell\Pycharm\pycharm-build.ps1" Write-Host "Запускаю функцию: " -ForegroundColor Gray -NoNewline Write-Host "Initialize-Dependencies" -ForegroundColor Cyan $RESULT = Initialize-Dependencies -IsDebug $false Write-Host "Результаты работы функции: " -ForegroundColor Gray -NoNewline Write-Host "Initialize-Dependencies" -ForegroundColor Cyan Write-Host "$FPROBEL `$RESULT.Code: " -ForegroundColor Gray -NoNewline Write-Host "$($RESULT.Code)" -ForegroundColor Cyan $RESULT.Msg = '' foreach ($Msg in $RESULT.output) { Write-Host "$FPROBEL `$RESULT.Msg: " -ForegroundColor Gray -NoNewline Write-Host "$Msg" -ForegroundColor Cyan } #Clear-Host $URL = "https://gper.ru/soft/Development/PyCharm/pycharm-2026.2.exe" $DST = "C:\temp" Write-Host "Запускаю функцию: " -ForegroundColor Gray -NoNewline Write-Host "Invoke-DownFile" -ForegroundColor Cyan $RESULT = Invoke-DownFile -Url "$URL" -Dst "$DST" -IsDebug $false Write-Host "Результаты работы функции: " -ForegroundColor Gray -NoNewline Write-Host "Invoke-DownFile" -ForegroundColor Cyan Write-Host "$FPROBEL `$RESULT.Code: " -ForegroundColor Gray -NoNewline Write-Host "$($RESULT.Code)" -ForegroundColor Cyan Write-Host "$FPROBEL `$RESULT.Msg: " -ForegroundColor Gray -NoNewline Write-Host "$($RESULT.Msg)" -ForegroundColor Cyan $URL = "https://gper.ru/soft/Development/PyCharm/Paths/PyCarm_path_2026.2.7z" $DST = "C:\temp" $RESULT = Invoke-DownFile -Url "$URL" -Dst "$DST" -IsDebug $false Write-Host "Результаты работы функции: " -ForegroundColor Gray -NoNewline Write-Host "Invoke-DownFile" -ForegroundColor Cyan Write-Host "$FPROBEL `$RESULT.Code: " -ForegroundColor Gray -NoNewline Write-Host "$($RESULT.Code)" -ForegroundColor Cyan Write-Host "$FPROBEL `$RESULT.Msg: " -ForegroundColor Gray -NoNewline Write-Host "$($RESULT.Msg)" -ForegroundColor Cyan $RESULT = Install-PyChqrm Write-Host "Результаты работы функции: " -ForegroundColor Gray -NoNewline Write-Host "Install-PyChqrm" -ForegroundColor Cyan Write-Host "$FPROBEL `$RESULT.Code: " -ForegroundColor Gray -NoNewline Write-Host "$($RESULT.Code)" -ForegroundColor Cyan #$RESULT.Msg = '' #foreach ($Msg in $RESULT.output) { Write-Host "$FPROBEL `$RESULT.Msg: " -ForegroundColor Gray -NoNewline Write-Host "$($RESULT.Msg)" -ForegroundColor Cyan #} #if ( $($RESULT.Code) -ne 0 ) { # $FMSG = "$($RESULT.Code) $($RESULT.Msg)" # Write-Host "$FMSG" -ForegroundColor Red # return #} } catch { Write-Host "Ошибка в функции Main: $_" -ForegroundColor Red } finally { if (!($PSM_EXIST)) { Invoke-EndProg } } } Main