Skip to content

Instantly share code, notes, and snippets.

@dmnc-net
Last active March 18, 2025 13:02
Show Gist options
  • Save dmnc-net/6fdb26204449a1e8ea5767c4520879c1 to your computer and use it in GitHub Desktop.
Save dmnc-net/6fdb26204449a1e8ea5767c4520879c1 to your computer and use it in GitHub Desktop.
Windows Python dev environment
# Check if the script is running with administrative privileges
if (-not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) {
Write-Output "Script is not running as Administrator. Attempting to restart with elevated privileges..."
# Relaunch the script with the RunAs verb to prompt for elevation
Start-Process -FilePath "powershell.exe" -ArgumentList "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`"" -Verb RunAs
exit
}
# Install PowerShell 7
Write-Output "Installing PowerShell 7..."
winget install --id Microsoft.PowerShell --exact --source winget
# Install Windows Terminal
Write-Output "Installing Windows Terminal..."
winget install --id Microsoft.WindowsTerminal --exact --source winget
# Install Visual Studio Code
Write-Output "Installing Visual Studio Code..."
winget install --id Microsoft.VisualStudioCode --exact --source winget
# Install Python
Write-Output "Installing Python..."
winget install --id Python.Python.3 --exact --source winget
# Enable Win32 long paths (for Python)
Write-Output "Enabling Win32 long paths..."
Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem" -Name LongPathsEnabled -Value 1
# Install VS Code Python extension
Write-Output "Installing the VS Code Python extension..."
code --install-extension ms-python.python
Write-Output "Installation complete!"
@dmnc-net
Copy link
Author

Because the system can block downloaded scripts, it is better to create an empty file and copy the content.

  • otherwise: Unblock-File -Path .\install-dev-tools.ps1
  • also this can be handy: powershell -ExecutionPolicy Bypass -File .\install-dev-tools.ps1 (or pwsh instead of powershell)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment