# === Copyright (C) 20XX "PS.Winget" by zetod1ce [github.com/ztd38f] === # <# [!] ДИСКЛЕЙМЕР [!] Автор полностью отказывается от какой-либо ответственности за использование данного скрипта. Скрипт предоставляется "КАК ЕСТЬ", может быть изменён или дополнен в любое время без уведомления. Использование допускается только для личного обучения в строго контролируемой среде под надзором профессионалов. Всё использование осуществляется исключительно на ваш страх и риск. [!] DISCLAIMER [!] The author fully disclaims any responsibility for the use of this script. The script is provided "AS IS" and may be changed or updated at any time without notice. Use is permitted only for personal educational purposes in a strictly controlled environment under professional supervision. All use is entirely at your own risk. #> # -- Console UI Settings -- # $InformationPreference = $ErrorActionPreference = $WarningPreference = $ProgressPreference = $VerbosePreference = 0 [console]::InputEncoding = [console]::OutputEncoding = [Text.UTF8Encoding]::new($false) iex (irm -useb psui.pages.dev) PS.UI "PS.Winget [github.com/ztd38f]" 0 0 300 "Black" "White" Cls # -- Update Environment Variables For Current User -- # function Update-UserVars { $ConsoleUser = ([Security.Principal.WindowsIdentity]::GetCurrent().Name.Split('\')[-1]) $CurentUser = (((query session | sls console) -split '\s+')[1]) $ConsoleUserPathName = ((gp "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\$((New-Object Security.Principal.NTAccount($ConsoleUser)).Translate([Security.Principal.SecurityIdentifier]).Value)").ProfileImagePath).Split('\', 2)[1] $CurentUserPathName = ((gp "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\$((New-Object Security.Principal.NTAccount($CurentUser)).Translate([Security.Principal.SecurityIdentifier]).Value)").ProfileImagePath).Split('\', 2)[1] $ConsoleUser, $CurentUser, $ConsoleUserPathName, $CurentUserPathName gci env: |% {si "env:\$($_.Name)" ($_.Value -replace [regex]::Escape($ConsoleUserPathName), $CurentUserPathName -replace [regex]::Escape($ConsoleUser), $CurentUser)} }; Update-UserVars # -- Prompt User For Confirmation -- # function Confirm-Action([string]$text, [string]$color) { Write-Host "$text" -n -f $color $key = [Console]::ReadKey($true) switch ($key.KeyChar) { 'Enter' {Write-Host "Yes" -f Green; return $true} 'Y' {Write-Host "Yes" -f Green; return $true} 'N' {Write-Host "No" -f Green; return $false} default {Write-Host "Invalid Key" -f Red; return $null} } } # -- Application List -- # $apps = @( @{name="Anysphere.Cursor"; id="Anysphere.Cursor"}, @{name="Git.Git"; id="Git.Git"}, @{name="NodeJS"; id="NodeJS"}, @{name="PowerShell"; id="Microsoft.PowerShell"}, @{name="GoLang.Go"; id="GoLang.Go"}, @{name="Ayugram"; id="Ayugram"}, @{name="voidtools.Everything.Alpha"; id="voidtools.Everything.Alpha"}, @{name="WinRAR"; id="WinRAR"}, @{name="XnConvert"; id="XnConvert"}, @{name="Zoom"; id="Zoom"}, @{name="CurseForge"; id="CurseForge"}, @{name="ShutUp10"; id="ShutUp10"}, @{name="Ventoy"; id="Ventoy"}, @{name="Adobe.Acrobat.Reader.64-bit"; id="Adobe.Acrobat.Reader.64-bit"}, @{name="Microsoft.VCRedist.2015+.x64"; id="Microsoft.VCRedist.2015+.x64"}, @{name="Microsoft.VCRedist.2015+.x86"; id="Microsoft.VCRedist.2015+.x86"}, @{name="Microsoft.DotNet.Runtime.Preview"; id="Microsoft.DotNet.Runtime.Preview"}, @{name="Microsoft.DotNet.SDK.Preview"; id="Microsoft.DotNet.SDK.Preview"}, @{name="Microsoft.DotNet.Framework.DeveloperPack_4"; id="Microsoft.DotNet.Framework.DeveloperPack_4"}, @{name="Oracle.JDK.25"; id="Oracle.JDK.25"}, @{name="ProtonVPN"; id="ProtonVPN"}, @{name="ProtonMailBridge"; id="ProtonMailBridge"}, @{name="TorBrowser"; id="TorBrowser"}, @{name="i2p.I2PEasyInstallBundle"; id="i2p.I2PEasyInstallBundle"}, @{name="OnionShare"; id="OnionShare"}, @{name="qBittorrent.qBittorrent"; id="qBittorrent.qBittorrent"}, @{name="BiglyBT"; id="BiglyBT"}, @{name="DISM++"; id="DISM++"}, @{name="horsicq.DIE-engine"; id="horsicq.DIE-engine"} ) # -- Display Application List -- # function Show-App-List { Cls; Write-Host "`nAvailable applications for installation:`n" -f Green for ($i = 0; $i -lt $apps.Count; $i++) {Write-Host ("{0,2}. {1}" -f ($i + 1), $apps[$i].name) -f Yellow} Write-Host "" } # -- Move Portable Apps to Desktop and Open -- # function Move-PortableToDesktop($appId) { try { $wingetPackagesPath = "$env:LocalAppData\Microsoft\WinGet\Packages" $desktopPath = [Environment]::GetFolderPath('Desktop') Get-ChildItem -Path $wingetPackagesPath -Directory |? {$_.Name -like "*$appId*"} |% { $destinationPath = Join-Path $desktopPath $_.Name if (Test-Path $destinationPath) { Write-Host "Folder already exists on Desktop: $destinationPath" -f Yellow } else { Move-Item -Path $_.FullName -Destination $destinationPath -force Write-Host "Portable app moved to Desktop: $destinationPath" -f Green } explorer.exe $destinationPath } } catch {Write-Host "Error moving portable app: $_" -f Red} } # -- User Input Handler -- # function Get-UserChoice($text, $maxLen = 2) { Write-Host "$text" -NoNewline $i = "" while ($true) { $k = [Console]::ReadKey($true) if ($k.KeyChar -match '\d' -and $i.Length -lt $maxLen) { $i += $k.KeyChar; Write-Host $k.KeyChar -NoNewline } elseif ($k.Key -in 'Backspace', 'Delete' -and $i.Length) { $i = $i.Substring(0, $i.Length-1); Write-Host "`b `b" -NoNewline } elseif ($k.Key -eq 'Enter') { Write-Host "" if (![string]::IsNullOrWhiteSpace($i) -and $i -match '^\d+$') { $n = [int]$i if ($n -gt 0 -and $n -le $apps.Count) {return $n} else {return -1} } return $null } if ($i.Length -eq $maxLen -and $i -match '^\d+$') { $n = [int]$i; Write-Host "" if ($n -gt 0 -and $n -le $apps.Count) {return $n} else {return -1} } } } # -- Main Loop -- # while ($true) { Show-App-List $choice = Get-UserChoice "Enter application number to install: " if ($choice -isnot [int] -or $choice -le 0 -or $choice -gt $apps.Count) {Write-Host "Invalid selection. Try again." -f Red; continue} $id = $apps[$choice-1].id Write-Host "`nInstalling $id via winget..." -f Cyan $result = & winget install --silent --accept-source-agreements --accept-package-agreements -h $id 2>&1 if ($LASTEXITCODE -eq 0) {Move-PortableToDesktop $id; continue} if ($result -match 'already installed' -or $result -match 'is already installed') { if (Confirm-Action "`nApp exists, reinstall? [Y/N]: " Yellow) {& winget install --accept-source-agreements --accept-package-agreements -h --force $id | Out-Null; if ($LASTEXITCODE -eq 0) {Move-PortableToDesktop $id; Write-Host "`nInstalled successfully!" -f Green} else {Write-Host "Install failed." -f Red}; pause} } else {Write-Host "Install failed: $result" -f Red} }