Commands for installing Python 2 without prompts, removing it again and detecting it from deployment tools. A command is shown only when it is certain: from the manifest or the installer technology’s documented default.
Related guide: Silent install switches: MSI, NSIS, Inno Setup · Uninstall a program with the registry or PowerShell
With winget
PowerShell
winget install --id Python.Python.2 -e --silent --accept-package-agreements --accept-source-agreementswinget upgrade --id Python.Python.2 -e --silentwinget uninstall --id Python.Python.2 -e --silentBy installer
64-bit · MSI · All users
Silent install
msiexec /i python-2.7.18.amd64.msi /qn /norestartWrite a log
msiexec /i python-2.7.18.amd64.msi /qn /norestart /l*v "%TEMP%\python-2-install.log"Uninstall
msiexec /x {A5F504DF-2ED9-4A2D-A2F3-9D2750DD42D6} /qn /norestart- MSI product code
- {A5F504DF-2ED9-4A2D-A2F3-9D2750DD42D6}
- Uninstall registry key
- HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{A5F504DF-2ED9-4A2D-A2F3-9D2750DD42D6}
32-bit · MSI · All users
Silent install
msiexec /i python-2.7.18.msi /qn /norestartWrite a log
msiexec /i python-2.7.18.msi /qn /norestart /l*v "%TEMP%\python-2-install.log"Uninstall
msiexec /x {A5F504DF-2ED9-4A2D-A2F3-9D2750DD42D5} /qn /norestart- MSI product code
- {A5F504DF-2ED9-4A2D-A2F3-9D2750DD42D5}
- Uninstall registry key
- HKLM\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{A5F504DF-2ED9-4A2D-A2F3-9D2750DD42D5}
PowerShell: download, verify, install
Downloads the official file, checks its SHA256 and installs it silently.
install-python-2.ps1
$url = 'https://www.python.org/ftp/python/2.7.18/python-2.7.18.amd64.msi'
$sha256 = 'B74A3AFA1E0BF2A6FC566A7B70D15C9BFABBA3756FB077797D16FFFA27800C05'
$file = Join-Path $env:TEMP 'python-2.7.18.amd64.msi'
Invoke-WebRequest -Uri $url -OutFile $file -UseBasicParsing
if ((Get-FileHash $file -Algorithm SHA256).Hash -ne $sha256) { throw 'SHA256 mismatch' }
Start-Process msiexec.exe -ArgumentList '/i', ('"{0}"' -f $file), '/qn', '/norestart' -Wait install-python-2.ps1
$url = 'https://www.python.org/ftp/python/2.7.18/python-2.7.18.msi'
$sha256 = 'D901802E90026E9BAD76B8A81F8DD7E43C7D7E8269D9281C9E9DF7A9C40480A9'
$file = Join-Path $env:TEMP 'python-2.7.18.msi'
Invoke-WebRequest -Uri $url -OutFile $file -UseBasicParsing
if ((Get-FileHash $file -Algorithm SHA256).Hash -ne $sha256) { throw 'SHA256 mismatch' }
Start-Process msiexec.exe -ArgumentList '/i', ('"{0}"' -f $file), '/qn', '/norestart' -Wait