-
Notifications
You must be signed in to change notification settings - Fork 10
/
Install.ps1
82 lines (75 loc) · 2.17 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
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
Function Test-CommandExists
{
Param ($command)
try { if (Get-Command $command) { RETURN $true } }
Catch { RETURN $false }
}
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor [System.Net.SecurityProtocolType]::Tls12
$ErrorActionPreference = 'stop'
if (!(Test-CommandExists winget))
{
echo "Installing latest winget..."
$DownloadURL = 'https://github.com/microsoft/winget-cli/releases/latest/download/Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle'
$FilePath = "$env:TEMP\WinGet.msixbundle"
try
{
Invoke-WebRequest -Uri $DownloadURL -UseBasicParsing -OutFile $FilePath
}
catch
{
Write-Error $_
Return
}
if (Test-Path $FilePath)
{
Add-AppxPackage $FilePath
$item = Get-Item -LiteralPath $FilePath
$item.Delete()
}
}
try
{
echo "Updating winget sources..."
echo ""
$progressPreference = 'silentlyContinue'
$latestWingetMsixBundleUri = $(Invoke-RestMethod https://api.github.com/repos/microsoft/winget-cli/releases/latest).assets.browser_download_url | Where-Object {$_.EndsWith(".msixbundle")}
$latestWingetMsixBundle = $latestWingetMsixBundleUri.Split("/")[-1]
Write-Information "Downloading winget to artifacts directory..."
Invoke-WebRequest -Uri $latestWingetMsixBundleUri -OutFile "./$latestWingetMsixBundle"
Invoke-WebRequest -Uri https://aka.ms/Microsoft.VCLibs.x64.14.00.Desktop.appx -OutFile Microsoft.VCLibs.x64.14.00.Desktop.appx
Add-AppxPackage Microsoft.VCLibs.x64.14.00.Desktop.appx
Add-AppxPackage $latestWingetMsixBundle
timeout /t 3 /nobreak
clear
}
catch
{
echo "Winget sources already up to date."
}
echo "Downloading script..."
$DownloadURL = 'https://github.com/harryeffinpotter/PC-Gaming-Redists-AIO/raw/main/AIOInstaller.bat'
$FilePath = "$env:TEMP\AIOInstaller.bat"
try
{
Invoke-WebRequest -Uri $DownloadURL -UseBasicParsing -OutFile $FilePath
}
catch
{
Invoke-WebRequest -Uri $DownloadURL -UseBasicParsing -OutFile $FilePath
Return
}
try
{
if (Test-Path $FilePath)
{
Start-Process -Verb runAs $FilePath -Wait
$item = Get-Item -LiteralPath $FilePath
$item.Delete()
}
}
catch
{
Start-Process -Verb runAs $FilePath -Wait
$item = Get-Item -LiteralPath $FilePath
$item.Delete()
}