Created
January 16, 2026 16:46
-
-
Save mepunit/717e88debf214815007f68a3c7da8e00 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # PowerShell script to install Node.js, Git, and Python without admin access | |
| # Run this script in PowerShell: .\install-dev-tools.ps1 | |
| $ErrorActionPreference = "Stop" | |
| # Create installation directory | |
| $InstallDir = "$env:USERPROFILE\DevTools" | |
| $NodeDir = "$InstallDir\nodejs" | |
| $GitDir = "$InstallDir\git" | |
| $PythonDir = "$InstallDir\python" | |
| Write-Host "Installing development tools to: $InstallDir" -ForegroundColor Green | |
| Write-Host "" | |
| # Create directories | |
| New-Item -ItemType Directory -Force -Path $InstallDir | Out-Null | |
| New-Item -ItemType Directory -Force -Path $NodeDir | Out-Null | |
| New-Item -ItemType Directory -Force -Path $GitDir | Out-Null | |
| New-Item -ItemType Directory -Force -Path $PythonDir | Out-Null | |
| # Function to download files | |
| function Download-File { | |
| param ( | |
| [string]$Url, | |
| [string]$Output | |
| ) | |
| Write-Host "Downloading: $Url" -ForegroundColor Cyan | |
| try { | |
| # Try using Invoke-WebRequest | |
| Invoke-WebRequest -Uri $Url -OutFile $Output -UseBasicParsing | |
| } catch { | |
| # Fallback to WebClient | |
| $webClient = New-Object System.Net.WebClient | |
| $webClient.DownloadFile($Url, $Output) | |
| } | |
| } | |
| # Function to extract zip files | |
| function Extract-Archive { | |
| param ( | |
| [string]$ZipFile, | |
| [string]$Destination | |
| ) | |
| Write-Host "Extracting: $ZipFile" -ForegroundColor Cyan | |
| Expand-Archive -Path $ZipFile -DestinationPath $Destination -Force | |
| } | |
| # Install Node.js (portable) | |
| Write-Host "`n=== Installing Node.js ===" -ForegroundColor Yellow | |
| $NodeVersion = "v20.11.0" | |
| $NodeUrl = "https://nodejs.org/dist/$NodeVersion/node-$NodeVersion-win-x64.zip" | |
| $NodeZip = "$InstallDir\nodejs.zip" | |
| Download-File -Url $NodeUrl -Output $NodeZip | |
| Extract-Archive -ZipFile $NodeZip -Destination $NodeDir | |
| # Move files from nested directory | |
| $ExtractedNodeDir = Get-ChildItem -Path $NodeDir -Directory | Select-Object -First 1 | |
| if ($ExtractedNodeDir) { | |
| Get-ChildItem -Path $ExtractedNodeDir.FullName | Move-Item -Destination $NodeDir -Force | |
| Remove-Item -Path $ExtractedNodeDir.FullName -Recurse -Force | |
| } | |
| Remove-Item $NodeZip | |
| Write-Host "Node.js installed to: $NodeDir" -ForegroundColor Green | |
| # Install Git (portable) | |
| Write-Host "`n=== Installing Git ===" -ForegroundColor Yellow | |
| $GitVersion = "2.43.0" | |
| $GitUrl = "https://github.com/git-for-windows/git/releases/download/v$GitVersion.windows.1/PortableGit-$GitVersion-64-bit.7z.exe" | |
| $GitInstaller = "$InstallDir\git-portable.exe" | |
| Download-File -Url $GitUrl -Output $GitInstaller | |
| # The portable Git is a self-extracting archive | |
| Write-Host "Extracting Git (this may take a moment)..." -ForegroundColor Cyan | |
| Start-Process -FilePath $GitInstaller -ArgumentList "-o`"$GitDir`"", "-y" -Wait -NoNewWindow | |
| Remove-Item $GitInstaller | |
| Write-Host "Git installed to: $GitDir" -ForegroundColor Green | |
| # Install Python (embeddable) | |
| Write-Host "`n=== Installing Python ===" -ForegroundColor Yellow | |
| $PythonVersion = "3.12.1" | |
| $PythonUrl = "https://www.python.org/ftp/python/$PythonVersion/python-$PythonVersion-embed-amd64.zip" | |
| $PythonZip = "$InstallDir\python.zip" | |
| Download-File -Url $PythonUrl -Output $PythonZip | |
| Extract-Archive -ZipFile $PythonZip -Destination $PythonDir | |
| Remove-Item $PythonZip | |
| # Configure Python to use pip | |
| $PthFile = Get-ChildItem -Path $PythonDir -Filter "*._pth" | Select-Object -First 1 | |
| if ($PthFile) { | |
| $content = Get-Content $PthFile.FullName | |
| $content = $content -replace "#import site", "import site" | |
| Set-Content -Path $PthFile.FullName -Value $content | |
| } | |
| # Download and install pip | |
| Write-Host "Installing pip..." -ForegroundColor Cyan | |
| $GetPipUrl = "https://bootstrap.pypa.io/get-pip.py" | |
| $GetPipFile = "$PythonDir\get-pip.py" | |
| Download-File -Url $GetPipUrl -Output $GetPipFile | |
| & "$PythonDir\python.exe" $GetPipFile --no-warn-script-location | |
| Remove-Item $GetPipFile | |
| Write-Host "Python installed to: $PythonDir" -ForegroundColor Green | |
| # Update PATH for current session | |
| Write-Host "`n=== Updating PATH ===" -ForegroundColor Yellow | |
| $env:Path = "$NodeDir;$GitDir\cmd;$PythonDir;$PythonDir\Scripts;$env:Path" | |
| # Add to user PATH permanently | |
| $CurrentPath = [Environment]::GetEnvironmentVariable("Path", "User") | |
| $PathsToAdd = @($NodeDir, "$GitDir\cmd", $PythonDir, "$PythonDir\Scripts") | |
| foreach ($PathToAdd in $PathsToAdd) { | |
| if ($CurrentPath -notlike "*$PathToAdd*") { | |
| $CurrentPath = "$PathToAdd;$CurrentPath" | |
| } | |
| } | |
| [Environment]::SetEnvironmentVariable("Path", $CurrentPath, "User") | |
| Write-Host "PATH updated for current and future sessions" -ForegroundColor Green | |
| # Verify installations | |
| Write-Host "`n=== Verifying Installations ===" -ForegroundColor Yellow | |
| Write-Host "" | |
| try { | |
| $nodeVersion = & "$NodeDir\node.exe" --version | |
| Write-Host "✓ Node.js: $nodeVersion" -ForegroundColor Green | |
| } catch { | |
| Write-Host "✗ Node.js verification failed" -ForegroundColor Red | |
| } | |
| try { | |
| $npmVersion = & "$NodeDir\npm.cmd" --version | |
| Write-Host "✓ npm: v$npmVersion" -ForegroundColor Green | |
| } catch { | |
| Write-Host "✗ npm verification failed" -ForegroundColor Red | |
| } | |
| try { | |
| $gitVersion = & "$GitDir\cmd\git.exe" --version | |
| Write-Host "✓ Git: $gitVersion" -ForegroundColor Green | |
| } catch { | |
| Write-Host "✗ Git verification failed" -ForegroundColor Red | |
| } | |
| try { | |
| $pythonVersion = & "$PythonDir\python.exe" --version | |
| Write-Host "✓ Python: $pythonVersion" -ForegroundColor Green | |
| } catch { | |
| Write-Host "✗ Python verification failed" -ForegroundColor Red | |
| } | |
| try { | |
| $pipVersion = & "$PythonDir\Scripts\pip.exe" --version | |
| Write-Host "✓ pip: $pipVersion" -ForegroundColor Green | |
| } catch { | |
| Write-Host "✗ pip verification failed" -ForegroundColor Red | |
| } | |
| Write-Host "`n=== Installation Complete! ===" -ForegroundColor Green | |
| Write-Host "" | |
| Write-Host "Tools installed to: $InstallDir" -ForegroundColor Cyan | |
| Write-Host "" | |
| Write-Host "IMPORTANT: Please restart your PowerShell or Command Prompt for PATH changes to take effect." -ForegroundColor Yellow | |
| Write-Host "Or run this command to update PATH in current session:" -ForegroundColor Yellow | |
| Write-Host "`$env:Path = `"$NodeDir;$GitDir\cmd;$PythonDir;$PythonDir\Scripts;`$env:Path`"" -ForegroundColor Cyan |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment