# ========================================================== # VARUNCODER - personal Windows toolkit # Run: irm varuncoder.me | iex # ========================================================== # # ==================== CONFIG (edit here) ==================== $ToolkitVersion = "1.0.0-phase1" $Site = "https://varuncoder.me" $ScriptUrl = "$Site/setup" $Api = "$Site/api.php" $DownloadDir = Join-Path $env:USERPROFILE "Downloads\varuncoder" # Local action log (never contains the password or the token) $LogDir = Join-Path $env:LOCALAPPDATA "VarunCoder" $LogPath = Join-Path $LogDir "toolkit.log" # ---- Your fixed "standard" app set ----------------------- $MyApps = @( "Git.Git", "Microsoft.VisualStudioCode", "Google.Chrome", "7zip.7zip", "VideoLAN.VLC", "Python.Python.3.12", "OpenJS.NodeJS.LTS", "Microsoft.WindowsTerminal", "Discord.Discord", "Microsoft.PowerToys" ) # ---- Catalog for "choose from list" (Name = shown, Id = winget id) ---- $Catalog = [ordered]@{ "Browsers" = @( @{Name="Google Chrome"; Id="Google.Chrome"}, @{Name="Mozilla Firefox";Id="Mozilla.Firefox"}, @{Name="Brave"; Id="Brave.Brave"}, @{Name="Opera"; Id="Opera.Opera"} ) "Developer" = @( @{Name="Git"; Id="Git.Git"}, @{Name="VS Code"; Id="Microsoft.VisualStudioCode"}, @{Name="Python 3.12"; Id="Python.Python.3.12"}, @{Name="Node.js LTS"; Id="OpenJS.NodeJS.LTS"}, @{Name="GitHub Desktop"; Id="GitHub.GitHubDesktop"}, @{Name="Docker Desktop"; Id="Docker.DockerDesktop"}, @{Name="Postman"; Id="Postman.Postman"}, @{Name="Notepad++"; Id="Notepad++.Notepad++"}, @{Name="Windows Terminal"; Id="Microsoft.WindowsTerminal"}, @{Name="IntelliJ IDEA (CE)"; Id="JetBrains.IntelliJIDEA.Community"} ) "Communication" = @( @{Name="Discord"; Id="Discord.Discord"}, @{Name="Telegram"; Id="Telegram.TelegramDesktop"}, @{Name="Zoom"; Id="Zoom.Zoom"}, @{Name="Slack"; Id="SlackTechnologies.Slack"} ) "Media" = @( @{Name="VLC"; Id="VideoLAN.VLC"}, @{Name="OBS Studio";Id="OBSProject.OBSStudio"}, @{Name="GIMP"; Id="GIMP.GIMP"}, @{Name="Audacity"; Id="Audacity.Audacity"}, @{Name="HandBrake"; Id="HandBrake.HandBrake"} ) "Gaming" = @( @{Name="Steam"; Id="Valve.Steam"}, @{Name="Epic Games"; Id="EpicGames.EpicGamesLauncher"}, @{Name="Ubisoft Connect";Id="Ubisoft.Connect"}, @{Name="EA App"; Id="ElectronicArts.EADesktop"} ) "Utilities" = @( @{Name="7-Zip"; Id="7zip.7zip"}, @{Name="Everything (file search)"; Id="voidtools.Everything"}, @{Name="PowerToys"; Id="Microsoft.PowerToys"}, @{Name="ShareX"; Id="ShareX.ShareX"}, @{Name="qBittorrent"; Id="qBittorrent.qBittorrent"}, @{Name="AnyDesk"; Id="AnyDesk.AnyDesk"}, @{Name="CPU-Z"; Id="CPUID.CPU-Z"}, @{Name="HWiNFO"; Id="REALiX.HWiNFO"} ) } # ==================== END CONFIG ==================== # ========================================================== # Local action log (%LOCALAPPDATA%\VarunCoder\toolkit.log) # ========================================================== function Write-Log([string]$Action, [string]$Detail = "") { try { if (-not (Test-Path $LogDir)) { New-Item -ItemType Directory -Force -Path $LogDir | Out-Null } $line = "{0}`t{1}`t{2}" -f (Get-Date -Format "yyyy-MM-dd HH:mm:ss"), $Action, $Detail Add-Content -Path $LogPath -Value $line -ErrorAction SilentlyContinue } catch { } } # ========================================================== # Helpers # ========================================================== function Write-Title($t) { Clear-Host Write-Host "" $banner = @( "# # ### #### # # # # #### ### #### ##### #### ", "# # # # # # # # ## # # # # # # # # #", " # # ##### #### # # # # # # # # # # ### #### ", " # # # # # # # # # ## # # # # # # # # ", " # # # # # ### # # #### ### #### ##### # #" ) # Fire gradient (red -> orange -> yellow), approximated with the 16 # standard console colors since -ForegroundColor has no custom RGB. $gradient = @("Red", "Red", "DarkYellow", "Yellow", "Yellow") for ($i = 0; $i -lt $banner.Count; $i++) { Write-Host $banner[$i] -ForegroundColor $gradient[$i] } Write-Host "" if ($t) { Write-Host " >> $t" -ForegroundColor Yellow; Write-Host "" } } function Write-Step($m) { Write-Host "`n==> $m" -ForegroundColor Cyan } function Write-Ok($m) { Write-Host " [OK] $m" -ForegroundColor Green } function Write-Bad($m) { Write-Host " [X] $m" -ForegroundColor Red } function Pause-Menu { Read-Host "`nPress Enter to continue" | Out-Null } function Confirm-Yes($q) { (Read-Host "$q (y/n)") -match '^[yY]' } function Format-Size([double]$b) { if ($b -ge 1GB) { return "{0:N2} GB" -f ($b / 1GB) } if ($b -ge 1MB) { return "{0:N1} MB" -f ($b / 1MB) } if ($b -ge 1KB) { return "{0:N0} KB" -f ($b / 1KB) } return "$b B" } # Turns "1,3,5-7" or "a" into a list of 0-based indexes function Get-Selection([string]$text, [int]$max) { $text = $text.Trim() if ($text -match '^[aA]$') { return 0..($max - 1) } $result = @() foreach ($part in ($text -split '[,\s]+')) { if ($part -match '^(\d+)-(\d+)$') { foreach ($n in [int]$Matches[1]..[int]$Matches[2]) { if ($n -ge 1 -and $n -le $max) { $result += $n - 1 } } } elseif ($part -match '^\d+$') { $n = [int]$part; if ($n -ge 1 -and $n -le $max) { $result += $n - 1 } } } return $result | Select-Object -Unique } function Test-Winget { if (Get-Command winget -ErrorAction SilentlyContinue) { return $true } Write-Bad "winget not found. Install 'App Installer' from the Microsoft Store first." return $false } # ========================================================== # System restore point (best-effort, before destructive/slow actions) # ========================================================== function New-ToolkitRestorePoint([string]$Reason) { try { Enable-ComputerRestore -Drive "$env:SystemDrive\" -ErrorAction SilentlyContinue Checkpoint-Computer -Description "VarunCoder: $Reason" -RestorePointType "MODIFY_SETTINGS" -ErrorAction Stop Write-Ok "System restore point created ($Reason)." Write-Log "RestorePoint" $Reason return $true } catch { # Windows only allows one restore point per 24h by default - that's fine, not fatal. Write-Host " [i] Couldn't create a restore point (often just the 24h limit): $($_.Exception.Message)" -ForegroundColor DarkYellow return $false } } # ========================================================== # Login (password checked on the server, never stored here) # ========================================================== $script:Token = $null function Invoke-Login { for ($i = 1; $i -le 3; $i++) { $sec = Read-Host " Password" -AsSecureString $bstr = [Runtime.InteropServices.Marshal]::SecureStringToBSTR($sec) $plain = [Runtime.InteropServices.Marshal]::PtrToStringAuto($bstr) [Runtime.InteropServices.Marshal]::ZeroFreeBSTR($bstr) try { $r = Invoke-RestMethod -Uri "$($Api)?action=login" -Method Post -Body @{ password = $plain } -UseBasicParsing $script:Token = $r.token Write-Ok "Welcome back, Varun!" Write-Log "Login" "OK" Start-Sleep -Milliseconds 700 return $true } catch { $code = 0 if ($_.Exception.Response) { $code = [int]$_.Exception.Response.StatusCode } if ($code -eq 429) { Write-Bad "Too many wrong attempts. Locked for 15 minutes."; Write-Log "Login" "LOCKED"; return $false } elseif ($code -eq 401) { Write-Bad "Wrong password ($i/3)"; Write-Log "Login" "WRONG_PASSWORD" } else { Write-Bad "Can't reach server: $($_.Exception.Message)"; Write-Log "Login" "SERVER_ERROR"; return $false } } finally { $plain = $null } } Write-Log "Login" "GAVE_UP" return $false } function Get-AuthHeader { @{ "X-Auth-Token" = $script:Token } } function Show-Notice { try { $r = Invoke-RestMethod -Uri "$($Api)?action=notice" -Headers (Get-AuthHeader) -UseBasicParsing if ($r.notice) { Write-Host " $($r.notice)`n" -ForegroundColor DarkCyan } } catch { } # a missing/failed notice should never block the menu } # ========================================================== # 1. Update all apps # ========================================================== function Update-All { Write-Title "Update all applications" Write-Log "UpdateAll" "start" if (-not (Test-Winget)) { return } Write-Step "Checking for updates..." winget upgrade --source winget if (Confirm-Yes "`nUpdate everything listed above?") { winget upgrade --all --source winget --accept-package-agreements --accept-source-agreements --silent Write-Ok "Updates finished." } if (Confirm-Yes "Open Windows Update too?") { Start-Process "ms-settings:windowsupdate" } } # ========================================================== # 2. Clean Windows # ========================================================== function Invoke-Clean { Write-Title "Clean Windows" Write-Log "Clean" "start" $before = (Get-PSDrive C).Free Write-Step "User temp files"; Remove-Item "$env:TEMP\*" -Recurse -Force -ErrorAction SilentlyContinue; Write-Ok "Done" Write-Step "Windows temp files"; Remove-Item "$env:SystemRoot\Temp\*" -Recurse -Force -ErrorAction SilentlyContinue; Write-Ok "Done" Write-Step "Recycle Bin"; Clear-RecycleBin -Force -ErrorAction SilentlyContinue; Write-Ok "Done" Write-Step "Windows Update download cache" Stop-Service wuauserv -Force -ErrorAction SilentlyContinue Remove-Item "$env:SystemRoot\SoftwareDistribution\Download\*" -Recurse -Force -ErrorAction SilentlyContinue Start-Service wuauserv -ErrorAction SilentlyContinue Write-Ok "Done" Write-Step "Delivery Optimization cache" try { Delete-DeliveryOptimizationCache -Force -ErrorAction Stop | Out-Null; Write-Ok "Done" } catch { Write-Ok "Skipped" } Write-Step "Thumbnail cache" Remove-Item "$env:LOCALAPPDATA\Microsoft\Windows\Explorer\thumbcache_*.db" -Force -ErrorAction SilentlyContinue Write-Ok "Done" Write-Step "DNS cache"; ipconfig /flushdns | Out-Null; Write-Ok "Done" if (Confirm-Yes "`nAlso run deep component cleanup (DISM, takes 5-15 min)?") { New-ToolkitRestorePoint "Clean - DISM component cleanup" | Out-Null Write-Log "Clean" "DISM component cleanup" DISM /Online /Cleanup-Image /StartComponentCleanup } $freed = (Get-PSDrive C).Free - $before if ($freed -lt 0) { $freed = 0 } Write-Host "`n Freed about $(Format-Size $freed) on C:" -ForegroundColor Green } # ========================================================== # 3. Install applications # ========================================================== function Install-Ids($ids) { $ok = 0; $fail = @() Write-Log "Install" ($ids -join ',') foreach ($id in $ids) { Write-Step "Installing $id" winget install --id $id -e --source winget --accept-package-agreements --accept-source-agreements --silent if ($LASTEXITCODE -eq 0) { $ok++ } else { $fail += $id } } Write-Host "`n Installed/OK: $ok" -ForegroundColor Green if ($fail.Count) { Write-Host " Failed or already installed: $($fail -join ', ')" -ForegroundColor Yellow } } function Install-Standard { Write-Title "Install my standard apps" $MyApps | ForEach-Object { Write-Host " - $_" } if (Confirm-Yes "`nInstall all of these?") { Install-Ids $MyApps } } function Install-FromCatalog { while ($true) { Write-Title "Choose a category" $cats = @($Catalog.Keys) for ($i = 0; $i -lt $cats.Count; $i++) { Write-Host (" {0}. {1}" -f ($i + 1), $cats[$i]) } Write-Host " 0. Back" $c = Read-Host "`n Pick" if ($c -eq "0") { return } if ($c -notmatch '^\d+$' -or [int]$c -lt 1 -or [int]$c -gt $cats.Count) { continue } $cat = $cats[[int]$c - 1] $apps = @($Catalog[$cat]) Write-Title "Install: $cat" for ($i = 0; $i -lt $apps.Count; $i++) { Write-Host (" {0}. {1}" -f ($i + 1), $apps[$i].Name) } Write-Host "`n Type numbers like 1,3,5 or 2-4, 'a' for all, Enter to go back" $sel = Read-Host " Pick" if (-not $sel) { continue } $idx = @(Get-Selection $sel $apps.Count) if ($idx.Count -eq 0) { continue } Install-Ids ($idx | ForEach-Object { $apps[$_].Id }) Pause-Menu } } function Install-Search { Write-Title "Search any app" $q = Read-Host " App name to search" if (-not $q) { return } winget search $q --source winget $id = Read-Host "`n Paste the exact Id to install (Enter to cancel)" if ($id) { Install-Ids @($id) } } function Show-InstallMenu { if (-not (Test-Winget)) { Pause-Menu; return } while ($true) { Write-Title "Install applications" Write-Host " 1. Install my standard apps (fixed set)" Write-Host " 2. Choose from list (by category)" Write-Host " 3. Search any app" Write-Host " 0. Back" switch (Read-Host "`n Pick") { "1" { Install-Standard; Pause-Menu } "2" { Install-FromCatalog } "3" { Install-Search; Pause-Menu } "0" { return } } } } # ========================================================== # 4/5. Personal & public folders (downloaded from server) # ========================================================== function Open-RemoteFolder([string]$folder, [string]$title) { Write-Log "OpenFolder" $folder while ($true) { Write-Title $title try { $r = Invoke-RestMethod -Uri "$($Api)?action=list&folder=$folder" -Headers (Get-AuthHeader) -UseBasicParsing } catch { $code = 0; if ($_.Exception.Response) { $code = [int]$_.Exception.Response.StatusCode } if ($code -eq 401) { Write-Bad "Session expired - log in again." if (Invoke-Login) { continue } else { return } } Write-Bad "Couldn't load folder: $($_.Exception.Message)"; Pause-Menu; return } $files = @($r.files) if ($files.Count -eq 0) { Write-Host " (folder is empty)"; Pause-Menu; return } for ($i = 0; $i -lt $files.Count; $i++) { Write-Host (" {0,3}. {1,-50} {2,10}" -f ($i + 1), $files[$i].name, (Format-Size $files[$i].size)) } Write-Host "`n Numbers like 1,3,5 or 2-4, 'a' for all, Enter to go back" $sel = Read-Host " Download" if (-not $sel) { return } $idx = @(Get-Selection $sel $files.Count) if ($idx.Count -eq 0) { continue } $dest = Join-Path $DownloadDir $folder $ProgressPreference = 'SilentlyContinue' # makes downloads much faster in PowerShell 5 foreach ($i in $idx) { $f = $files[$i] if ($f.name -match '\.\.') { continue } $out = Join-Path $dest ($f.name -replace '/', '\') New-Item -ItemType Directory -Force -Path (Split-Path $out) | Out-Null Write-Host " Downloading $($f.name) ($(Format-Size $f.size))..." -NoNewline try { $u = "$($Api)?action=download&folder=$folder&file=$([uri]::EscapeDataString($f.name))" Invoke-WebRequest -Uri $u -Headers (Get-AuthHeader) -OutFile $out -UseBasicParsing Write-Host " done" -ForegroundColor Green Write-Log "Download" "$folder/$($f.name)" } catch { Write-Host " failed: $($_.Exception.Message)" -ForegroundColor Red } } $ProgressPreference = 'Continue' Write-Ok "Saved to $dest" if (Confirm-Yes "Open the folder?") { Start-Process explorer.exe $dest } } } # ========================================================== # Extras # ========================================================== function Show-SystemInfo { Write-Title "System info" Write-Log "SystemInfo" "" $os = Get-CimInstance Win32_OperatingSystem $cs = Get-CimInstance Win32_ComputerSystem $cpu = Get-CimInstance Win32_Processor | Select-Object -First 1 $gpu = (Get-CimInstance Win32_VideoController | ForEach-Object Name) -join ", " $up = (Get-Date) - $os.LastBootUpTime Write-Host " PC name : $($env:COMPUTERNAME) ($($cs.Manufacturer) $($cs.Model))" Write-Host " Windows : $($os.Caption) build $($os.BuildNumber)" Write-Host " CPU : $($cpu.Name.Trim())" Write-Host " GPU : $gpu" Write-Host (" RAM : {0} total, {1} free" -f (Format-Size $cs.TotalPhysicalMemory), (Format-Size ($os.FreePhysicalMemory * 1KB))) Write-Host (" Uptime : {0}d {1}h {2}m" -f $up.Days, $up.Hours, $up.Minutes) Get-CimInstance Win32_LogicalDisk -Filter "DriveType=3" | ForEach-Object { Write-Host (" Disk {0} : {1} free of {2}" -f $_.DeviceID, (Format-Size $_.FreeSpace), (Format-Size $_.Size)) } $bat = Get-CimInstance Win32_Battery -ErrorAction SilentlyContinue if ($bat) { Write-Host " Battery : $($bat.EstimatedChargeRemaining)%" } $ip = Get-NetIPAddress -AddressFamily IPv4 -ErrorAction SilentlyContinue | Where-Object { $_.InterfaceAlias -notmatch 'Loopback' -and $_.IPAddress -notlike '169.*' } | Select-Object -First 1 if ($ip) { Write-Host " Local IP: $($ip.IPAddress) ($($ip.InterfaceAlias))" } } function Repair-Network { Write-Title "Fix internet / network" Write-Host " This resets DNS, IP and Winsock. Your internet will drop for a few seconds." if (-not (Confirm-Yes "Continue?")) { return } New-ToolkitRestorePoint "Network reset" | Out-Null Write-Log "RepairNetwork" "start" ipconfig /flushdns | Out-Null; Write-Ok "DNS flushed" ipconfig /release | Out-Null; ipconfig /renew | Out-Null; Write-Ok "IP renewed" netsh winsock reset | Out-Null; Write-Ok "Winsock reset" netsh int ip reset | Out-Null; Write-Ok "TCP/IP reset" Write-Host "`n Restart your PC to finish." -ForegroundColor Yellow } function Repair-Windows { Write-Title "Repair Windows files" Write-Host " Runs DISM RestoreHealth + SFC scan. Takes 10-30 minutes." if (-not (Confirm-Yes "Start?")) { return } New-ToolkitRestorePoint "Repair Windows (DISM + SFC)" | Out-Null Write-Log "RepairWindows" "start" DISM /Online /Cleanup-Image /RestoreHealth sfc /scannow } function Set-RegValue($path, $name, $value) { if (-not (Test-Path $path)) { New-Item -Path $path -Force | Out-Null } New-ItemProperty -Path $path -Name $name -Value $value -PropertyType DWord -Force | Out-Null } function Show-TweaksMenu { while ($true) { Write-Title "Windows tweaks" Write-Host " 1. Dark mode" Write-Host " 2. Show file extensions + hidden files" Write-Host " 3. Classic right-click menu (Windows 11)" Write-Host " 4. Remove Bing/web results from Start search" Write-Host " 5. High performance power plan" Write-Host " 6. Apply ALL of the above" Write-Host " 0. Back" $c = Read-Host "`n Pick" if ($c -eq "0") { return } if ($c -in "1","2","3","4","5","6") { New-ToolkitRestorePoint "Windows tweaks" | Out-Null Write-Log "Tweaks" $c } $theme = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize" $adv = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" if ($c -in "1","6") { Set-RegValue $theme AppsUseLightTheme 0; Set-RegValue $theme SystemUsesLightTheme 0; Write-Ok "Dark mode" } if ($c -in "2","6") { Set-RegValue $adv HideFileExt 0; Set-RegValue $adv Hidden 1; Write-Ok "File extensions + hidden files visible" } if ($c -in "3","6") { reg add "HKCU\Software\Classes\CLSID\{86ca1aa0-34aa-4e8b-a509-50c905bae2a2}\InprocServer32" /f /ve | Out-Null Write-Ok "Classic right-click menu" } if ($c -in "4","6") { Set-RegValue "HKCU:\Software\Microsoft\Windows\CurrentVersion\Search" BingSearchEnabled 0 Set-RegValue "HKCU:\Software\Policies\Microsoft\Windows\Explorer" DisableSearchBoxSuggestions 1 Write-Ok "Web results removed from Start" } if ($c -in "5","6") { powercfg /setactive SCHEME_MIN | Out-Null; Write-Ok "High performance power plan" } if ($c -in "1","2","3","4","6") { Stop-Process -Name explorer -Force -ErrorAction SilentlyContinue; Write-Ok "Explorer restarted" } Pause-Menu } } # ========================================================== # Main # ========================================================== function Start-Toolkit { # Relaunch as Administrator (needed for installs, cleaning, repairs) $isAdmin = ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole( [Security.Principal.WindowsBuiltInRole]::Administrator) if (-not $isAdmin) { Write-Host "Opening as Administrator..." -ForegroundColor Yellow Start-Process powershell -Verb RunAs -ArgumentList "-NoProfile -ExecutionPolicy Bypass -Command `"irm '$ScriptUrl' | iex`"" return } [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 $Host.UI.RawUI.WindowTitle = "VARUNCODER toolkit" Write-Title "Login" if (-not (Invoke-Login)) { Write-Host "`n Bye." -ForegroundColor Red; Start-Sleep 2; return } Write-Log "Toolkit" "started v$ToolkitVersion" $noticeShown = $false while ($true) { Write-Title "Main menu" if (-not $noticeShown) { Show-Notice; $noticeShown = $true } Write-Host " 1. Update all applications" Write-Host " 2. Clean Windows (temp, cache, recycle bin)" Write-Host " 3. Install applications" Write-Host " 4. Personal folder (my private files)" Write-Host " 5. Public folder" Write-Host " ---------------------------------" Write-Host " 6. System info" Write-Host " 7. Windows tweaks" Write-Host " 8. Fix internet / network" Write-Host " 9. Repair Windows files (SFC + DISM)" Write-Host " 0. Exit" switch (Read-Host "`n Pick") { "1" { Update-All; Pause-Menu } "2" { Invoke-Clean; Pause-Menu } "3" { Show-InstallMenu } "4" { Open-RemoteFolder "personal" "Personal folder" } "5" { Open-RemoteFolder "public" "Public folder" } "6" { Show-SystemInfo; Pause-Menu } "7" { Show-TweaksMenu } "8" { Repair-Network; Pause-Menu } "9" { Repair-Windows; Pause-Menu } "0" { $script:Token = $null; Write-Host "`n Bye, Varun!" -ForegroundColor Green; return } } } } Start-Toolkit