-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinstall.ps1
53 lines (44 loc) · 1.93 KB
/
install.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# install.ps1
# This script initiates the Dotbot installation process for Windows,
# including Python installation if necessary
# Function to check if running as administrator
function Test-Admin {
$currentUser = New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent())
$currentUser.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
}
# Check if running with administrator privileges
if (-not (Test-Admin)) {
Write-Host "This script requires administrator privileges. Please run as administrator." -ForegroundColor Red
exit 1
}
# Function to install Python using winget
function Install-Python {
Write-Host "Python is not installed. Attempting to install Python..." -ForegroundColor Yellow
# Check if winget is available
if (Get-Command winget -ErrorAction SilentlyContinue) {
winget install Python.Python.3.11
if ($LASTEXITCODE -ne 0) {
Write-Host "Failed to install Python using winget. Please install Python manually and retry." -ForegroundColor Red
exit 1
}
}
else {
Write-Host "Winget is not available. Please install Python manually and retry." -ForegroundColor Red
exit 1
}
# Refresh environment variables
$env:Path = [System.Environment]::GetEnvironmentVariable("Path", "Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path", "User")
}
# Check for Python installation
if (-not (Get-Command python -ErrorAction SilentlyContinue)) {
Install-Python
}
# Verify Python installation
if (-not (Get-Command python -ErrorAction SilentlyContinue)) {
Write-Host "Python installation failed or PATH was not updated. Please install Python manually and retry." -ForegroundColor Red
exit 1
}
# Execute Dotbot
Write-Host "Executing Dotbot..." -ForegroundColor Green
python "dotbot\bin\dotbot" -c "windows.yaml"
Write-Host "Installation process completed." -ForegroundColor Green