-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.ps1
More file actions
304 lines (277 loc) · 8.64 KB
/
install.ps1
File metadata and controls
304 lines (277 loc) · 8.64 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
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
$AppList = @(
# WinGet apps
[PSCustomObject] @{
Name = "DirectX"
ID = "Microsoft.DirectX"
}
[PSCustomObject] @{
Name = "Microsoft Visual C++ 2015-2022"
ID = "Microsoft.VCRedist.2015+.x64"
}
[PSCustomObject] @{
Name = "PowerShell 7"
ID = "Microsoft.PowerShell"
}
[PSCustomObject] @{
Name = "WindowsTerminal"
ID = "Microsoft.WindowsTerminal"
}
[PSCustomObject] @{
Name = "MozillaFirefox"
ID = "Mozilla.Firefox"
}
[PSCustomObject] @{
Name = "MsiAfterburner"
ID = "Guru3D.Afterburner"
}
[PSCustomObject] @{
Name = "NVCleanstall"
ID = "TechPowerUp.NVCleanstall"
}
[PSCustomObject] @{
Name = "GoodbyeDPI UI"
ID = "Storik4pro.GoodbyeDPI-UI"
}
[PSCustomObject] @{
Name = "NanaZip"
ID = "M2Team.NanaZip"
}
[PSCustomObject] @{
Name = "UniGetUI"
ID = "MartiCliment.UniGetUI"
}
[PSCustomObject] @{
Name = "MPC-HC"
ID = "clsid2.mpc-hc"
}
[PSCustomObject] @{
Name = "Git"
ID = "Git.Git"
}
[PSCustomObject] @{
Name = "Visual Studio Code"
ID = "Microsoft.VisualStudioCode"
}
[PSCustomObject] @{
Name = "qBittorrent"
ID = "qBittorrent.qBittorrent.lt2"
}
[PSCustomObject] @{
Name = "Oh My Posh"
ID = "JanDeDobbeleer.OhMyPosh"
}
[PSCustomObject] @{
Name = "Flow Launcher"
ID = "Flow-Launcher.low-Launcher"
}
[PSCustomObject] @{
Name = "Double Commander"
ID = "alexx2000.DoubleCommander"
}
)
function Install-Application
{
param (
[Parameter(Mandatory = $true)]
[PSCustomObject]$App
)
Write-Host "Now installing $($App.Name)" -ForegroundColor Yellow
winget install --id $App.ID --exact --source winget --accept-source-agreements --disable-interactivity --silent --accept-package-agreements --force
if ($LASTEXITCODE -ne 0 )
{
Write-Error "A error occurred while installing $($App.Name)."
return $false
}
Write-Host "$($App.Name) successfully installed."
return $true
}
function Test-InternetConnection
{
Write-Host "Testing internet connection..." -ForegroundColor Yellow
try
{
Test-Connection -ComputerName www.google.com -Count 3 -Delay 1 -ErrorAction Stop | Out-Null
return $true
}
catch
{
Write-Warning "Internet connection isn't available. Please check your connection."
return $false
}
}
function Test-WindowsActivation
{
Write-Host "Testing Windows activation..." -ForegroundColor Yellow
if ((Get-CIMInstance -Query "SELECT * FROM SoftwareLicensingProduct WHERE LicenseStatus = 1").LicenseStatus)
{
return $true
}
else
{
Write-Warning "Windows activation wasn't found."
return $false
}
}
function Install-WindowsActivation
{
try
{
Write-Host "Starting Windows activation script..." -ForegroundColor Yellow
Invoke-RestMethod https://get.activated.win | Invoke-Expression -ErrorAction Stop
return $true
}
catch
{
Write-Error "Error: $_"
return $false
}
}
function Test-WinGetInstallation
{
Write-Host "Testing WinGet installation..." -ForegroundColor Yellow
try
{
winget --version
return $true
}
catch
{
Write-Warning "WinGet installation wasn't found."
return $false
}
}
function Install-WinGet
{
try
{
Write-Host "Installing WinGet PowerShell module from PSGallery..." -ForegroundColor Yellow
Install-PackageProvider -Name NuGet -Force -ErrorAction Stop | Out-Null
Install-Module -Name Microsoft.WinGet.Client -Force -Repository PSGallery -ErrorAction Stop | Out-Null
Write-Host "Using Repair-WinGetPackageManager cmdlet to bootstrap WinGet..." -ForegroundColor Yellow
Repair-WinGetPackageManager -AllUsers -ErrorAction Stop
Write-Host "WinGet installation is complete." -ForegroundColor Yellow
return $true # Success
}
catch
{
Write-Error "Error: $_"
return $false # Failure
}
}
function Set-GitUserVars
{
param (
[Parameter(Mandatory = $true, HelpMessage = "Enter the git user.name")]
[string] $Name,
[Parameter(Mandatory = $true, HelpMessage = "Enter the git user.email")]
[string] $Email
)
git config --global user.name $Name
git config --global user.email $Email
}
function Set-WindowsDefenderStatus
{
param (
[Parameter(Mandatory = $true)]
[bool] $Enabled
)
$output = "$env:TEMP\defender-control.exe"
if ($Enabled)
{
$url = "https://github.com/pgkt04/defender-control/releases/latest/download/enable-defender.exe"
}
else
{
$url = "https://github.com/pgkt04/defender-control/releases/latest/download/disable-defender.exe"
}
try
{
Write-Host "Working on Windows Defender..." -ForegroundColor Yellow
Invoke-RestMethod -Uri $url -OutFile $output -UseBasicParsing -ErrorAction Stop
Start-Process -FilePath $output -Wait
Remove-Item $output -Force
}
catch
{
Write-Error "Error: $_"
}
}
function Set-DefaultFileManager
{
param (
[Parameter(Mandatory = $true)]
[ValidateSet("Explorer", "DoubleCommander")]
[string] $Name
)
switch ($Name)
{
"Explorer"
{
# Win + E hotkey bind
$regPath = "HKCU:\SOFTWARE\Classes\CLSID\{52205fd8-5dfb-447d-801a-d0b52f2e83e1}"
Remove-Item -Path $regPath -Recurse -Force
# Shell integration
Set-ItemProperty -Path "Registry::HKEY_CLASSES_ROOT\Drive\Shell" -Name "(Default)" -Value "none"
Remove-Item -Path "Registry::HKEY_CLASSES_ROOT\Drive\shell\open\command" -Recurse -Force
Set-ItemProperty -Path "Registry::HKEY_CLASSES_ROOT\Directory\shell" -Name "(Default)" -Value "none"
Remove-Item -Path "Registry::HKEY_CLASSES_ROOT\Directory\shell\open\command" -Recurse -Force
}
"DoubleCommander"
{
# Win + E hotkey bind
$regPath = "HKCU:\SOFTWARE\Classes\CLSID\{52205fd8-5dfb-447d-801a-d0b52f2e83e1}"
New-Item -Path "$regPath\shell\opennewwindow\command" -Force
Set-ItemProperty -Path "$regPath\shell\opennewwindow\command" -Name "(Default)" -Value '"C:\Program Files\Double Commander\doublecmd.exe" "-C"'
Set-ItemProperty -Path "$regPath\shell\opennewwindow\command" -Name "DelegateExecute" -Value ""
# Shell integration
New-Item -Path "Registry::HKEY_CLASSES_ROOT\Drive\shell\open\command" -Force
New-Item -Path "Registry::HKEY_CLASSES_ROOT\Directory\shell\open\command" -Force
Set-ItemProperty -Path "Registry::HKEY_CLASSES_ROOT\Drive\Shell" -Name "(Default)" -Value "open"
Set-ItemProperty -Path "Registry::HKEY_CLASSES_ROOT\Directory\shell" -Name "(Default)" -Value "open"
Set-ItemProperty -Path "Registry::HKEY_CLASSES_ROOT\Drive\shell\open\command" -Name "(Default)" -Value 'C:\Program Files\Double Commander\doublecmd.exe -C -P L -T "%1"'
Set-ItemProperty -Path "Registry::HKEY_CLASSES_ROOT\Directory\shell\open\command" -Name "(Default)" -Value 'C:\Program Files\Double Commander\doublecmd.exe -C -P L -T "%1"'
}
Default
{
Write-Error "Error: $_"
}
}
}
function Main
{
if (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator))
{
Write-Warning "Script needs to be run as Administrator!"
Write-Host "Press any key to exit."
Read-Host
break
}
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
if (!(Test-InternetConnection)) { break }
if (!(Test-WindowsActivation))
{
if (!(Install-WindowsActivation))
{
break
}
}
if (!(Test-WinGetInstallation))
{
if (!(Install-WinGet))
{
break
}
}
foreach ($app in $AppList)
{
if (!(Install-Application -App $app)) { continue }
}
Set-GitUserVars
Set-WindowsDefenderStatus -Enabled $false
Set-DefaultFileManager -Name DoubleCommander
Invoke-RestMethod "https://christitus.com/win" | Invoke-Expression -ErrorAction Stop
Write-Host "Script execution succeeded." -ForegroundColor Yellow
Write-Host "Press any key to exit."
Read-Host
}
Main