fix/feat: Unify WSL(g) 2 / Preview install to let the script decide which WSL is better

main
Plínio Larrubia 2 years ago committed by Plínio Larrubia
parent a99cb671ba
commit fb9a0d098e
No known key found for this signature in database
GPG Key ID: 057B0A87CB137C69

@ -139,7 +139,6 @@ Set-ExecutionPolicy Unrestricted -Scope CurrentUser -Force; ls -Recurse *.ps*1 |
- Help improve the Security of Windows while maintaining performance; ([`optimize-security.ps1`](./src/scripts/optimize-security.ps1))
- Remove OneDrive completely from the System, re-install is possible via Win Store; ([`remove-onedrive.ps1`](./src/scripts/remove-onedrive.ps1))
- Disable/Enable Windows Features specially for Gaming/Productivity; ([`optimize-windows-features.ps1`](./src/scripts/optimize-windows-features.ps1))
- Install WSL Preview (Only works for Windows 11); ([`win11-wsl-preview-install.ps1`](./src/scripts/win11-wsl-preview-install.ps1))
- In the End it only locks Local Machine script execution. ([`set-script-policy.psm1`](./src/lib/set-script-policy.psm1))
</details>

@ -20,8 +20,7 @@ function Open-Script() {
"personal-tweaks.ps1",
"optimize-security.ps1",
"remove-onedrive.ps1",
"optimize-windows-features.ps1",
"win11-wsl-preview-install.ps1"
"optimize-windows-features.ps1"
)
Open-PowerShellFilesCollection -RelativeLocation "src\scripts" -Scripts $Scripts -DoneTitle $DoneTitle -DoneMessage $DoneMessage -OpenFromGUI $false

@ -1,4 +1,4 @@
function Request-AdminPrivilege() {
function Request-AdminPrivilege() {
# Used from https://stackoverflow.com/a/31602095 because it preserves the working directory!
If (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) { Start-Process powershell.exe "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`"" -Verb RunAs; exit }
}
@ -13,7 +13,7 @@ function Show-GUI() {
$DoneMessage = "Process Completed!"
# Main Window:
$Form = New-Form -Width ($FormWidth + 15) -Height $FormHeight -Text "Win 10+ S. D. Tools | LeDragoX | $(Get-SystemSpec)" -BackColor "$WinDark" -Minimize $true # Loading the specs takes longer to load the script
$Form = New-Form -Width ($FormWidth + 15) -Height $FormHeight -Text "Win 10+ S. D. Tools (LeDragoX) | $(Get-SystemSpec)" -BackColor "$WinDark" -Minimize $true # Loading the specs takes longer to load the script
# Window Icon:
$Form = New-FormIcon -Form $Form -ImageLocation "$PSScriptRoot\src\assets\windows-11-logo.png"
@ -328,12 +328,9 @@ function Show-GUI() {
# Panel 4 ~> Small Buttons
$NextYLocation = $CaptionLabel4_7.Location.Y + $ButtonHeight + $DistanceBetweenButtons
$WSL2 = New-CheckBox -Text "WSL2 + WSLg (Win10 / Insider)" -Width $ButtonWidth -Height $ButtonHeight -LocationX $ButtonX -LocationY $NextYLocation -FontSize $FontSize1 -ForeColor $WinBlue
$WSLTwoOrPreview = New-CheckBox -Text "WSL2(g) / Preview (Win 10+)" -Width $ButtonWidth -Height $ButtonHeight -LocationX $ButtonX -LocationY $NextYLocation -FontSize $FontSize1 -ForeColor $WinBlue
$NextYLocation = $WSL2.Location.Y + $WSL2.Height + $DistanceBetweenButtons
$WSLPreview = New-CheckBox -Text "WSL Preview (Win 11)" -Width $ButtonWidth -Height $ButtonHeight -LocationX $ButtonX -LocationY $NextYLocation -FontSize $FontSize1 -ForeColor $WinBlue
$NextYLocation = $WSLPreview.Location.Y + $WSLPreview.Height + $DistanceBetweenButtons
$NextYLocation = $WSLTwoOrPreview.Location.Y + $WSLTwoOrPreview.Height + $DistanceBetweenButtons
$ArchWSL = New-CheckBox -Text "ArchWSL (x64)" -Width $ButtonWidth -Height $ButtonHeight -LocationX $ButtonX -LocationY $NextYLocation -FontSize $FontSize1 -ForeColor $WinBlue
$NextYLocation = $ArchWSL.Location.Y + $ArchWSL.Height + $DistanceBetweenButtons
@ -514,7 +511,7 @@ function Show-GUI() {
$Panel4.Controls.AddRange(@($CaptionLabel4_4, $BalenaEtcher, $Rufus, $Ventoy))
$Panel4.Controls.AddRange(@($CaptionLabel4_5, $Notion, $Obsidian))
$Panel4.Controls.AddRange(@($CaptionLabel4_6, $CPUZ, $CrystalDiskInfo, $CrystalDiskMark, $GPUZ, $NVCleanstall))
$Panel4.Controls.AddRange(@($CaptionLabel4_7, $WSL2, $WSLPreview, $ArchWSL, $Debian, $KaliLinux, $OpenSuse, $SLES, $Ubuntu, $Ubuntu16LTS, $Ubuntu18LTS, $Ubuntu20LTS))
$Panel4.Controls.AddRange(@($CaptionLabel4_7, $WSLTwoOrPreview, $ArchWSL, $Debian, $KaliLinux, $OpenSuse, $SLES, $Ubuntu, $Ubuntu16LTS, $Ubuntu18LTS, $Ubuntu20LTS))
$Panel5.Controls.AddRange(@($InstallGamingDependencies, $CaptionLabel5_1, $Discord, $MSTeams, $RocketChat, $Slack, $TelegramDesktop, $Zoom))
$Panel5.Controls.AddRange(@($CaptionLabel5_2, $BorderlessGaming, $EADesktop, $EpicGamesLauncher, $GogGalaxy, $Steam, $UbisoftConnect))
$Panel5.Controls.AddRange(@($CaptionLabel5_3, $AnyDesk, $Parsec, $ScrCpy, $TeamViewer))
@ -538,8 +535,7 @@ function Show-GUI() {
"personal-tweaks.ps1",
"optimize-security.ps1",
"remove-onedrive.ps1",
"optimize-windows-features.ps1",
"win11-wsl-preview-install.ps1"
"optimize-windows-features.ps1"
)
Open-PowerShellFilesCollection -RelativeLocation "src\scripts" -Scripts $Scripts -DoneTitle $DoneTitle -DoneMessage $DoneMessage
@ -956,18 +952,11 @@ function Show-GUI() {
$NVCleanstall.CheckState = "Unchecked"
}
If ($WSL2.CheckState -eq "Checked") {
If (!($Script:UninstallSwitch)) {
Open-PowerShellFilesCollection -RelativeLocation "src\utils" -Scripts @("win10-wsl2-wslg-install.ps1") -DoneTitle $DoneTitle -DoneMessage $DoneMessage
}
$WSL2.CheckState = "Unchecked"
}
If ($WSLPreview.CheckState -eq "Checked") {
If ($WSLTwoOrPreview.CheckState -eq "Checked") {
If (!($Script:UninstallSwitch)) {
Open-PowerShellFilesCollection -RelativeLocation "src\scripts" -Scripts @("win11-wsl-preview-install.ps1") -DoneTitle $DoneTitle -DoneMessage $DoneMessage
Open-PowerShellFilesCollection -RelativeLocation "src\utils" -Scripts @("wslg-or-preview-install.ps1") -DoneTitle $DoneTitle -DoneMessage $DoneMessage
}
$WSLPreview.CheckState = "Unchecked"
$WSLTwoOrPreview.CheckState = "Unchecked"
}
If ($ArchWSL.CheckState -eq "Checked") {

Binary file not shown.

Before

Width:  |  Height:  |  Size: 375 KiB

After

Width:  |  Height:  |  Size: 376 KiB

@ -39,7 +39,7 @@ function Optimize-WindowsFeaturesList() {
"FaxServicesClientPackage" # Windows Fax and Scan
"IIS-*" # Internet Information Services
"LegacyComponents" # Legacy Components
#"MediaPlayback" # Media Features (Windows Media Player)
"MediaPlayback" # Media Features (Windows Media Player)
"MicrosoftWindowsPowerShellV2" # PowerShell 2.0
"MicrosoftWindowsPowershellV2Root" # PowerShell 2.0
"Printing-PrintToPDFServices-Features" # Microsoft Print to PDF
@ -66,10 +66,6 @@ function Optimize-WindowsFeaturesList() {
"NetFx3" # NET Framework 3.5
"NetFx4-AdvSrvs" # NET Framework 4
"NetFx4Extended-ASPNET45" # NET Framework 4.x + ASPNET 4.x
# WSL 2 Support Semi-Install
"HypervisorPlatform" # Hypervisor Platform from Windows
"Microsoft-Windows-Subsystem-Linux" # WSL (VT-d (Intel) or SVM (AMD) need to be enabled on BIOS)
"VirtualMachinePlatform" # VM Platform
)
ForEach ($Feature in $EnableFeatures) {

@ -1,30 +0,0 @@
Import-Module -DisableNameChecking $PSScriptRoot\..\lib\"title-templates.psm1"
function WSLPreviewInstall() {
$TweakType = "WSL"
Try {
Write-Status -Symbol "?" -Type $TweakType "Installing WSL Preview from MS Store for Windows 11+ ..." -Warning
Write-Host "[?] Press 'Y' and ENTER to continue if stuck (Winget bug) ..." -ForegroundColor Magenta -BackgroundColor Black
$CheckExistenceBlock = { winget install --source "msstore" --id 9P9TQF7MRM4R --accept-package-agreements }
$err = $null
$err = (Invoke-Expression "$CheckExistenceBlock") | Out-Host
If (($LASTEXITCODE)) { throw $err } # 0 = False, 1 = True
Write-Status -Symbol "+" -Type $TweakType -Status "WSL Preview (Win 11+) successfully installed!"
Write-Status -Symbol "-" -Type $TweakType -Status "Uninstalling WSL from Optional Features ..."
Get-WindowsOptionalFeature -Online -FeatureName "Microsoft-Windows-Subsystem-Linux" | Where-Object State -Like "Enabled" | Disable-WindowsOptionalFeature -Online -NoRestart
Write-Status -Symbol "@" -Status "Updating WSL (if possible) ..."
wsl --update
}
Catch {
Write-Status -Symbol "?" -Type $TweakType -Status "Couldn't install WSL Preview, you must be at least on Windows 11 ..." -Warning
}
}
function Main {
WSLPreviewInstall
}
Main

@ -1,11 +1,38 @@
Import-Module -DisableNameChecking $PSScriptRoot\..\lib\"download-web-file.psm1"
Import-Module -DisableNameChecking $PSScriptRoot\..\lib\"get-hardware-info.psm1"
Import-Module -DisableNameChecking $PSScriptRoot\..\lib\"install-software.psm1"
Import-Module -DisableNameChecking $PSScriptRoot\..\lib\"title-templates.psm1"
function WSLwithGraphicsInstall() {
$OSArchList = Get-OSArchitecture
function Install-WSLPreview() {
[CmdletBinding()] param()
$TweakType = "WSL"
Try {
Write-Status -Symbol "?" -Type $TweakType "Installing WSL Preview from MS Store for Windows 11+ ..." -Warning
Write-Host "[?] Press 'Y' and ENTER to continue if stuck (Winget bug) ..." -ForegroundColor Magenta -BackgroundColor Black
$CheckExistenceBlock = { Install-Software -Name "WSL Preview (Win 11+)" -Packages "9P9TQF7MRM4R" -ViaMSStore -NoDialog }
$err = $null
$err = (Invoke-Expression "$CheckExistenceBlock") | Out-Host
If (($LASTEXITCODE)) { throw $err } # 0 = False, 1 = True
Write-Status -Symbol "-" -Type $TweakType -Status "Uninstalling WSL from Optional Features ..."
Get-WindowsOptionalFeature -Online -FeatureName "Microsoft-Windows-Subsystem-Linux" | Where-Object State -Like "Enabled" | Disable-WindowsOptionalFeature -Online -NoRestart
Write-Status -Symbol "@" -Type $TweakType -Status "Updating WSL (if possible) ..."
wsl --update
}
Catch {
Write-Status -Symbol "?" -Type $TweakType -Status "Couldn't install WSL Preview, you must be at least on Windows 11 ..." -Warning
Install-WSLTwoAndG
}
}
function Install-WSLTwoAndG() {
[CmdletBinding()] param()
$OSArchList = Get-OSArchitecture
If ([System.Environment]::OSVersion.Version.Build -eq 14393) {
# 1607 needs developer mode to be enabled for older Windows 10 versions
Write-Status -Symbol "+" -Type $TweakType -Status "Enabling Development mode w/out license and trusted apps (Win 10 1607)"
@ -13,10 +40,12 @@ function WSLwithGraphicsInstall() {
Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\AppModelUnlock" -Name "AllowAllTrustedApps" -Type DWord -Value 1
}
Write-Status -Symbol "+" -Type "Features" -Status "Installing Microsoft-Windows-Subsystem-Linux..."
Get-WindowsOptionalFeature -Online -FeatureName "Microsoft-Windows-Subsystem-Linux" | Where-Object State -Like "Disabled*" | Enable-WindowsOptionalFeature -Online -NoRestart
Write-Status -Symbol "+" -Type "Features" -Status "Installing VirtualMachinePlatform..."
Get-WindowsOptionalFeature -Online -FeatureName "VirtualMachinePlatform" | Where-Object State -Like "Disabled*" | Enable-WindowsOptionalFeature -Online -NoRestart
Write-Status -Symbol "+" -Type $TweakType -Status "Installing Microsoft-Windows-Subsystem-Linux..."
Get-WindowsOptionalFeature -Online -FeatureName "Microsoft-Windows-Subsystem-Linux" | Where-Object State -Like "Disabled*" | Enable-WindowsOptionalFeature -Online -NoRestart # WSL (VT-d (Intel) or SVM (AMD) need to be enabled on BIOS)
Write-Status -Symbol "+" -Type $TweakType -Status "Installing VirtualMachinePlatform..."
Get-WindowsOptionalFeature -Online -FeatureName "VirtualMachinePlatform" | Where-Object State -Like "Disabled*" | Enable-WindowsOptionalFeature -Online -NoRestart # VM Platform
Write-Status -Symbol "+" -Type $TweakType -Status "Installing HypervisorPlatform..."
Get-WindowsOptionalFeature -Online -FeatureName "HypervisorPlatform" | Where-Object State -Like "Disabled*" | Enable-WindowsOptionalFeature -Online -NoRestart # Hypervisor Platform from Windows
ForEach ($OSArch in $OSArchList) {
If ($OSArch -like "x64" -or "arm64") {
@ -32,7 +61,7 @@ function WSLwithGraphicsInstall() {
Start-Process -FilePath $WSLgOutput -ArgumentList "/passive" -Wait
Remove-Item -Path $WSLgOutput
Write-Status -Symbol "@" -Status "Updating WSL (if possible)..."
Write-Status -Symbol "@" -Type $TweakType -Status "Updating WSL (if possible)..."
wsl --update
}
Else {
@ -42,8 +71,8 @@ function WSLwithGraphicsInstall() {
}
}
function Main() {
WSLwithGraphicsInstall
function Main {
Install-WSLPreview
}
Main
Loading…
Cancel
Save