Skip to content

Commit c6e5004

Browse files
committed
Update SFX.ps1
1 parent 40bcd74 commit c6e5004

File tree

1 file changed

+25
-11
lines changed

1 file changed

+25
-11
lines changed

Scripts/SFX.ps1

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Write-Verbose -Message SFX -Verbose
22

3-
# Download WinRAR
3+
# Download WinRAR and 7-Zip to expand winrar-x64-713.exe as WinRAR fails to install
44
# https://www.rarlab.com
55
New-Item -Path WinRAR -ItemType Directory -Force
66

@@ -11,17 +11,31 @@ $Parameters = @{
1111
}
1212
Invoke-WebRequest @Parameters
1313

14-
# Install WinRAR silently
15-
& "WinRAR\winrar-x64-713.exe" -s1
14+
# Download the latest 7-Zip x64
15+
$Parameters = @{
16+
Uri = "https://sourceforge.net/projects/sevenzip/best_release.json"
17+
UseBasicParsing = $true
18+
Verbose = $true
19+
}
20+
$bestRelease = (Invoke-RestMethod @Parameters).platform_releases.windows.filename.replace("exe", "msi")
21+
22+
$Parameters = @{
23+
Uri = "https://unlimited.dl.sourceforge.net/project/sevenzip$($bestRelease)?viasf=1"
24+
OutFile = "WinRAR\7Zip.msi"
25+
UseBasicParsing = $true
26+
Verbose = $true
27+
}
28+
Invoke-WebRequest @Parameters
1629

17-
Get-ChildItem -Path "$env:ProgramFiles"
18-
test-path -Path "$env:ProgramFiles\WinRAR"
19-
Test-Path -Path "$env:ProgramFiles\WinRAR\WinRAR.exe"
30+
# Expand 7Zip.msi
31+
$Arguments = @(
32+
"/a `"WinRAR\7Zip.msi`""
33+
"TARGETDIR=`"WinRAR\7zip`""
34+
"/qb"
35+
)
36+
Start-Process "msiexec" -ArgumentList $Arguments -Wait
2037

21-
Import-Module -Name PackageManagement -UseWindowsPowerShell -Force
22-
Get-Package -Name *WinRAR* | fl *
23-
test-path -Path "$env:ProgramFiles\WinRAR"
24-
Test-Path -Path "$env:ProgramFiles\WinRAR\WinRAR.exe"
38+
& "WinRAR\7zip\Files\7-Zip\7z.exe" x "WinRAR\winrar-x64-713.exe" -o"WinRAR"
2539

2640
# Get latest version tag for Windows 11
2741
$Parameters = @{
@@ -33,4 +47,4 @@ $Latest_Release_Windows_11_PowerShell_5_1 = (Invoke-RestMethod @Parameters).Soph
3347
(Get-Content -Path Scripts\SFX_config.txt -Encoding utf8NoBOM -Raw) | Foreach-Object -Process {$_ -replace "SophiaScriptVersion", $Latest_Release_Windows_11_PowerShell_5_1} | Set-Content -Path Scripts\SFX_config.txt -Encoding utf8NoBOM -Force
3448

3549
# Create SFX archive
36-
& "$env:ProgramFiles\WinRAR\Rar.exe" a -sfx -z"Scripts\SFX_config.txt" -ep1 -r "Sophia.Script.for.Windows.11.v$($Latest_Release_Windows_11_PowerShell_5_1)_WinGet.exe" "Sophia_Script_for_Windows_11_v$($Latest_Release_Windows_11_PowerShell_5_1)\*"
50+
& "WinRAR\Rar.exe" a -sfx -z"Scripts\SFX_config.txt" -ep1 -r "Sophia.Script.for.Windows.11.v$($Latest_Release_Windows_11_PowerShell_5_1)_WinGet.exe" "Sophia_Script_for_Windows_11_v$($Latest_Release_Windows_11_PowerShell_5_1)\*"

0 commit comments

Comments
 (0)