From dbb4a085b003f2d80bd51e93285aa928d37750c8 Mon Sep 17 00:00:00 2001 From: 1552980358 <1552980358@qq.com> Date: Sun, 7 Apr 2024 20:09:55 +0800 Subject: [PATCH 1/2] Fix Windows 10 installation Appx commands error when pwsh.exe installed Issue PowerShell/PowerShell#19031 still exists on Windows 10 and still not be fixed --- MagiskOnWSA/installer/Install.ps1 | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/MagiskOnWSA/installer/Install.ps1 b/MagiskOnWSA/installer/Install.ps1 index afb8626..fa91475 100644 --- a/MagiskOnWSA/installer/Install.ps1 +++ b/MagiskOnWSA/installer/Install.ps1 @@ -38,6 +38,10 @@ function Get-InstalledDependencyVersion { } } +Function Check-Windows11 { + RETURN (Get-ComputerInfo | Select-Object -expand OsName) -match 11 +} + Function Test-CommandExist { Param ($Command) $OldPreference = $ErrorActionPreference @@ -53,10 +57,9 @@ Function Finish { Start-Process "wsa://com.android.vending" } -If (Test-CommandExist pwsh.exe) { +If (Check-Windows11 -And Test-CommandExist pwsh.exe) { $pwsh = "pwsh.exe" -} -Else { +} Else { $pwsh = "powershell.exe" } From c67866a280bfec4a75f0b2fac4d1b8bde323b79e Mon Sep 17 00:00:00 2001 From: 1552980358 <1552980358@qq.com> Date: Sun, 7 Apr 2024 21:25:24 +0800 Subject: [PATCH 2/2] Optimize readability --- MagiskOnWSA/installer/Install.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MagiskOnWSA/installer/Install.ps1 b/MagiskOnWSA/installer/Install.ps1 index fa91475..2043e33 100644 --- a/MagiskOnWSA/installer/Install.ps1 +++ b/MagiskOnWSA/installer/Install.ps1 @@ -57,7 +57,7 @@ Function Finish { Start-Process "wsa://com.android.vending" } -If (Check-Windows11 -And Test-CommandExist pwsh.exe) { +If ((Check-Windows11) -And (Test-CommandExist 'pwsh.exe')) { $pwsh = "pwsh.exe" } Else { $pwsh = "powershell.exe"