-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.ps1
More file actions
211 lines (184 loc) Β· 9.92 KB
/
install.ps1
File metadata and controls
211 lines (184 loc) Β· 9.92 KB
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
## install.ps1 (Simplified - No File Associations)
# Windows Application Bulk Installer
# Installs essential applications via WinGet and restores Windows 10 context menu
param(
[switch]$Force,
[switch]$AcceptAll
)
# Color output functions
function Write-Success { param($Message) Write-Host "β
$Message" -ForegroundColor Green }
function Write-Warning { param($Message) Write-Host "β οΈ $Message" -ForegroundColor Yellow }
function Write-Info { param($Message) Write-Host "π§ $Message" -ForegroundColor Cyan }
function Write-Error { param($Message) Write-Host "β $Message" -ForegroundColor Red }
# Check if running as Administrator
function Test-Administrator {
$currentUser = [Security.Principal.WindowsIdentity]::GetCurrent()
$principal = New-Object Security.Principal.WindowsPrincipal($currentUser)
return $principal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
}
# WinGet error code explanations
function Get-WinGetErrorExplanation {
param([int]$ExitCode)
switch ($ExitCode) {
-1978335189 { return "Already installed (same version)" }
-1978335226 { return "Newer version already installed" }
-2147024228 { return "Access denied or permissions issue" }
-1978335221 { return "Package not found" }
-1978335222 { return "Multiple packages found" }
-1978335233 { return "Package installation failed" }
default { return "Unknown error (code: $ExitCode)" }
}
}
# Application list
$applications = @(
@{ Name = "File Converter"; ID = "AdrienAllard.FileConverter"; Scope = ""; Note = "Default scope - winget decides" },
@{ Name = "Cursor Editor"; ID = "Anysphere.Cursor"; Scope = "user" },
@{ Name = "cURL"; ID = "cURL.cURL"; Scope = "user" },
@{ Name = "Microsoft .NET Desktop Runtime 9"; ID = "Microsoft.DotNet.DesktopRuntime.9"; Scope = ""; Note = "Dependency for Remote Desktop Manager" },
@{ Name = "Remote Desktop Manager"; ID = "Devolutions.RemoteDesktopManager"; Scope = ""; Note = "Default scope with .NET Runtime dependency" },
@{ Name = "Paint.NET"; ID = "dotPDN.PaintDotNet"; Scope = ""; Note = "Default scope - may require admin" },
@{ Name = "FireDaemon OpenSSL 3"; ID = "FireDaemon.OpenSSL"; Scope = ""; Note = "Default scope - may require admin" },
@{ Name = "Which for Windows"; ID = "GnuWin32.Which"; Scope = "user" },
@{ Name = "Wget2"; ID = "GNU.Wget2"; Scope = "user" },
@{ Name = "Google Chrome (EXE)"; ID = "Google.Chrome.EXE"; Scope = "user"; Note = "User-installable EXE version" },
@{ Name = "HashCheck Shell Extension"; ID = "idrassi.HashCheckShellExtension"; Scope = ""; Note = "Default scope - shell extension" },
@{ Name = "Mozilla Firefox"; ID = "Mozilla.Firefox"; Scope = ""; Note = "Default scope - winget decides" },
@{ Name = "7-Zip"; ID = "7zip.7zip"; Scope = ""; Note = "Default scope - winget decides" },
@{ Name = "Wget"; ID = "JernejSimoncic.Wget"; Scope = "user" },
@{ Name = "UniGetUI"; ID = "MartiCliment.UniGetUI"; Scope = "user"; Note = "GUI for package managers" },
@{ Name = "PowerToys"; ID = "Microsoft.PowerToys"; Scope = "user" },
@{ Name = "PowerShell 7"; ID = "Microsoft.PowerShell"; Scope = ""; Note = "Default scope - updates existing installation" },
@{ Name = "Sysinternals Suite"; ID = "Microsoft.Sysinternals.Suite"; Scope = "user" },
@{ Name = "Visual Studio Code"; ID = "Microsoft.VisualStudioCode"; Scope = "user" },
@{ Name = "OpenHashTab"; ID = "namazso.OpenHashTab"; Scope = "user" },
@{ Name = "Notepad++"; ID = "Notepad++.Notepad++"; Scope = ""; Note = "Default scope - winget decides" },
@{ Name = "foobar2000"; ID = "PeterPawlowski.foobar2000"; Scope = ""; Note = "Default scope - winget decides" },
@{ Name = "PuTTY"; ID = "PuTTY.PuTTY"; Scope = ""; Note = "Default scope - winget decides" },
@{ Name = "ShareX"; ID = "ShareX.ShareX"; Scope = "user" },
@{ Name = "VideoLAN VLC"; ID = "VideoLAN.VLC"; Scope = ""; Note = "Default scope - winget decides" },
@{ Name = "Git"; ID = "Git.Git"; Scope = "user" },
@{ Name = "WinSCP"; ID = "WinSCP.WinSCP"; Scope = "user" }
)
Write-Host "π Windows Application Bulk Installer" -ForegroundColor Magenta
Write-Host "π¦ Installing $($applications.Count) applications with Windows 10 context menu restoration`n" -ForegroundColor Yellow
# Check administrator privileges
$isAdmin = Test-Administrator
$defaultApps = $applications | Where-Object { $_.Scope -eq "" }
if (-not $isAdmin) {
Write-Warning "β οΈ Administrator privileges recommended for:"
Write-Host " β’ $($defaultApps.Count) default-scope applications" -ForegroundColor Yellow
Write-Host " β’ Windows 10 context menu restoration" -ForegroundColor Yellow
Write-Host "`nβ© Continuing with current permissions..." -ForegroundColor Yellow
}
# Check if winget is available
if (-not (Get-Command winget -ErrorAction SilentlyContinue)) {
Write-Error "WinGet is not available. Please install the App Installer from Microsoft Store."
exit 1
}
# Installation counters
$successCount = 0
$failedCount = 0
$skippedCount = 0
$failedApps = @()
# Set common parameters
$commonParams = @()
if ($AcceptAll) {
$commonParams += "--accept-package-agreements"
$commonParams += "--accept-source-agreements"
}
if ($Force) {
$commonParams += "--force"
}
Write-Info "Starting installation process..."
Write-Host ""
# Install each application
foreach ($app in $applications) {
$appName = $app.Name
$appID = $app.ID
$appScope = $app.Scope
$appNote = $app.Note
Write-Info "Installing: $appName ($appID)"
# Build install command
if ($appScope -eq "") {
$installArgs = @("install", "--id", $appID) + $commonParams
Write-Host " π― Using default scope (winget chooses)" -ForegroundColor DarkGray
} else {
$installArgs = @("install", "--id", $appID, "--scope", $appScope) + $commonParams
Write-Host " π Using $appScope scope" -ForegroundColor DarkGray
}
if ($appNote) {
Write-Host " π‘ Note: $appNote" -ForegroundColor DarkGray
}
try {
$result = & winget @installArgs 2>&1
$exitCode = $LASTEXITCODE
if ($exitCode -eq 0) {
$scopeText = if ($appScope -eq "") { "default" } else { $appScope }
Write-Success "β $appName installed/updated successfully (scope: $scopeText)"
$successCount++
} elseif ($exitCode -eq -1978335189) {
Write-Warning "β $appName already installed - skipping"
$skippedCount++
} else {
$explanation = Get-WinGetErrorExplanation -ExitCode $exitCode
Write-Error "β $appName installation failed - $explanation"
$failedApps += @{ Name = $appName; ID = $appID; Scope = $appScope; ExitCode = $exitCode; Explanation = $explanation }
$failedCount++
}
} catch {
Write-Error "β $appName installation error: $($_.Exception.Message)"
$failedApps += @{ Name = $appName; ID = $appID; Scope = $appScope; Error = $_.Exception.Message }
$failedCount++
}
Write-Host ""
}
# **WINDOWS 10 CONTEXT MENU RESTORATION**
Write-Host "π§ Post-Installation Configuration" -ForegroundColor Magenta
Write-Info "Restoring Windows 10 context menu..."
try {
& reg.exe add "HKCU\Software\Classes\CLSID\{86ca1aa0-34aa-4e8b-a509-50c905bae2a2}\InprocServer32" /f /ve
if ($LASTEXITCODE -eq 0) {
Write-Success "Windows 10 context menu restored successfully"
Write-Host " π‘ Note: Restart File Explorer or reboot to see changes" -ForegroundColor DarkGray
} else {
Write-Warning "Windows 10 context menu restoration may have failed (exit code: $LASTEXITCODE)"
}
} catch {
Write-Error "Failed to restore Windows 10 context menu: $($_.Exception.Message)"
}
# Display summary
Write-Host "`nπ Installation Summary:" -ForegroundColor Magenta
Write-Host " β
Successfully installed/updated: $successCount applications" -ForegroundColor Green
Write-Host " β οΈ Already installed/skipped: $skippedCount applications" -ForegroundColor Yellow
Write-Host " β Failed installations: $failedCount applications" -ForegroundColor Red
Write-Host " π¦ Total processed: $($applications.Count) applications" -ForegroundColor Cyan
# Show failed apps if any
if ($failedApps.Count -gt 0) {
Write-Host "`nβ Failed Applications:" -ForegroundColor Red
foreach ($failedApp in $failedApps) {
$scopeText = if ($failedApp.Scope -eq "") { "default" } else { $failedApp.Scope }
Write-Host " β’ $($failedApp.Name) ($($failedApp.ID)) [scope: $scopeText]" -ForegroundColor Gray
if ($failedApp.Explanation) {
Write-Host " Reason: $($failedApp.Explanation)" -ForegroundColor Yellow
}
}
Write-Host "`nπ‘ Retry failed installations:" -ForegroundColor Yellow
Write-Host " β’ Run as Administrator if access denied" -ForegroundColor Gray
Write-Host " β’ Use --force flag for newer version errors" -ForegroundColor Gray
}
# Final notes
Write-Host "`nπ Installation Complete!" -ForegroundColor Green
Write-Host "`nπ Next Steps:" -ForegroundColor Yellow
Write-Host " 1. Restart File Explorer or reboot to see context menu changes" -ForegroundColor Gray
Write-Host " 2. Configure file associations manually as needed" -ForegroundColor Gray
Write-Host " 3. Check Windows Start Menu for newly installed apps" -ForegroundColor Gray
Write-Host "`nπ§ Scope Summary:" -ForegroundColor Cyan
$userApps = $applications | Where-Object { $_.Scope -eq "user" }
$defaultApps = $applications | Where-Object { $_.Scope -eq "" }
Write-Host " β’ User scope: $($userApps.Count) applications" -ForegroundColor Green
Write-Host " β’ Default scope: $($defaultApps.Count) applications" -ForegroundColor Yellow
# Keep window open at the end of your FastApps script
Write-Host ""
Write-Host "β
FastApps installation completed!" -ForegroundColor Green
Write-Host "βΈοΈ Press Enter to close this window..." -ForegroundColor Yellow
Read-Host