-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall_python.ps1
37 lines (31 loc) · 1.19 KB
/
install_python.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# Set the version and download URL for Python
$version = "3.13.0"
$url = "https://www.python.org/ftp/python/$version/python-$version-amd64.exe"
$logFile = "$env:TEMP\python_install_log.txt"
# Define a function to log messages to the log file and display to the user
function Log_Message {
param (
[string]$message
)
Add-Content -Path $logFile -Value $message
Write-Host $message
}
# Notify user and download Python installer
Log-Message "Downloading Python $version from $url..."
Invoke-WebRequest $url -OutFile python-$version.exe
Log-Message "Download completed."
# Notify user and install Python
Log-Message "Installing Python $version..."
Start-Process python-$version.exe -ArgumentList "/quiet", "InstallAllUsers=1", "PrependPath=1" -Wait
Log-Message "Python installation completed."
# Clean up
Log-Message "Cleaning up..."
Remove-Item python-$version.exe
Log-Message "Cleanup completed."
# Restart the setup batch file and notify user
Log-Message "Restarting setup.bat..."
Start-Process cmd -ArgumentList "/c setup.bat restart" -Wait
Log-Message "Restart of setup.bat completed."
# Exit the script
Log-Message "Exiting PowerShell script."
Exit