From 167569c0433cdc74dc747eb62061ba8193f4050e Mon Sep 17 00:00:00 2001 From: Pete Batard Date: Wed, 20 Feb 2019 16:08:57 +0100 Subject: [PATCH] Don't display special Korean/Chinese versions by default * Also simplify some of the script --- Fido.ps1 | 210 ++++++++++++++++++++++++++----------------------------- 1 file changed, 101 insertions(+), 109 deletions(-) diff --git a/Fido.ps1 b/Fido.ps1 index 28c6bcd..ac27100 100644 --- a/Fido.ps1 +++ b/Fido.ps1 @@ -18,14 +18,7 @@ # # NB: You must have a BOM on your .ps1 if you want Powershell to actually -# realise it should use Unicode for the UI controls and not ISO-8859-1 - -# TODO: -# - Add a -NoHide param -# - Display all arch links? -# - Icon does not display in taskbar when shell window is reduced -# - Validate that download links are from Microsoft servers -# - Add Expert mode for Home China and suff? +# realise it should use Unicode for the UI rather than ISO-8859-1. #region Parameters param( @@ -33,7 +26,7 @@ param( # If not provided, a browser window is opened instead. [string]$PipeName, # (Optional) '|' separated UI localization strings. - [string]$Messages, + [string]$LocData, # (Optional) Path to the file that should be used for the UI icon. [string]$Icon, # (Optional) The title to display on the application window @@ -44,6 +37,7 @@ param( #region Testing $Debug = $False $Testing = $False +$Expert = $False #endregion Write-Host Please Wait... @@ -54,10 +48,10 @@ $code = @" internal static extern IntPtr LoadLibrary(string lpLibFileName); [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true, BestFitMapping = false, ThrowOnUnmappableChar = true)] internal static extern int LoadString(IntPtr hInstance, uint wID, StringBuilder lpBuffer, int nBufferMax); -[DllImport("Shell32.dll", CharSet = CharSet.Auto, SetLastError = true, BestFitMapping = false, ThrowOnUnmappableChar = true)] +[DllImport("shell32.dll", CharSet = CharSet.Auto, SetLastError = true, BestFitMapping = false, ThrowOnUnmappableChar = true)] internal static extern int ExtractIconEx(string sFile, int iIndex, out IntPtr piLargeVersion, out IntPtr piSmallVersion, int amountIcons); [DllImport("user32.dll")] - public static extern bool ShowWindow(int handle, int state); + public static extern bool ShowWindow(IntPtr handle, int state); // Returns a localized MUI string from the specified DLL public static string GetMuiString(string dll, uint index) @@ -90,7 +84,7 @@ $code = @" Add-Type -MemberDefinition $code -Namespace Gui -UsingNamespace "System.IO", "System.Text", "System.Drawing", "System.Globalization" -ReferencedAssemblies System.Drawing -Name Utils -ErrorAction Stop Add-Type -AssemblyName PresentationFramework # Hide the powershell window: https://stackoverflow.com/a/27992426/1069307 -$null = [Gui.Utils]::ShowWindow(([System.Diagnostics.Process]::GetCurrentProcess() | Get-Process).MainWindowHandle, 0) +[Gui.Utils]::ShowWindow(([System.Diagnostics.Process]::GetCurrentProcess() | Get-Process).MainWindowHandle, 0) | Out-Null #endregion #region Data @@ -102,51 +96,51 @@ $WindowsVersions = @( "1809 R2 (Build 17763.107 - 2018.10)", @("Windows 10 Home/Pro", 1060), @("Windows 10 Education", 1056), - @("Windows 10 Home China ", 1061) + @("Windows 10 Home China ", -1061) ), @( "1809 R1 (Build 17763.1 - 2018.09)", @("Windows 10 Home/Pro", 1019), @("Windows 10 Education", 1021), - @("Windows 10 Home China ", 1020) + @("Windows 10 Home China ", -1020) ), @( "1803 (Build 17134.1 - 2018.04)", @("Windows 10 Home/Pro", 651), @("Windows 10 Education", 655), - @("Windows 10 Enterprise Eval", 629) - @("Windows 10 COEM 1803 Home China", 640), - @("Windows 10 COEM 1803", 639), - @("Windows 10 1803 Home China", 638), + @("Windows 10 Enterprise Eval", -629) + @("Windows 10 COEM 1803 Home China", -640), + @("Windows 10 COEM 1803", -639), + @("Windows 10 1803 Home China", -638), @("Windows 10 1803", 637), - @("Windows 10 COEM 1803_1 Home China", 654), - @("Windows 10 COEM 1803_1", 653), - @("Windows 10 1803_1 Home China", 652) + @("Windows 10 COEM 1803_1 Home China", -654), + @("Windows 10 COEM 1803_1", -653), + @("Windows 10 1803_1 Home China", -652) ), @( "1709 (Build 16299.15 - 2017.09)", @("Windows 10 Education 1709", 488), - @("Windows 10 COEM 1709 Home China", 487), - @("Windows 10 COEM 1709", 486), - @("Windows 10 1709 Home China", 485), + @("Windows 10 COEM 1709 Home China", -487), + @("Windows 10 COEM 1709", -486), + @("Windows 10 1709 Home China", -485), @("Windows 10 1709", 484) ), @( "1703 (Build 15063.0 - 2017.03)", @("Windows 10 1703 Education N", 424), @("Windows 10 1703 Education", 423), - @("Windows 10 COEM 1703 Home China", 372), + @("Windows 10 COEM 1703 Home China", -372), @("Windows 10 COEM 1703 Single Language", 371), @("Windows 10 COEM 1703 N", 370), @("Windows 10 COEM 1703", 369), - @("Windows 10 1703 Home China (Redstone 2)", 364), - @("Windows 10 1703 Single Language (Redstone 2)", 363), + @("Windows 10 1703 Home China (Redstone 2)", -364), + @("Windows 10 1703 Single Language (Redstone 2)", -363), @("Windows 10 1703 N (Redstone 2)", 362), @("Windows 10 1703 (Redstone 2)", 361) ), @( "1607 (Build 14393.0 - 2017.07)", - @("Windows 10 China Get Genuine (Redstone 1)", 247), + @("Windows 10 China Get Genuine (Redstone 1)", -247), @("Windows 10 Single Language (Redstone 1)", 246), @("Windows 10 N (Redstone 1)", 245), @("Windows 10 (Redstone 1)", 244), @@ -155,12 +149,12 @@ $WindowsVersions = @( ), @( "1511 R3 (Build 10586.164 - 2016.04)", - @("Windows 10 China Get Genuine (Threshold 2, April 2016 Update)", 185), + @("Windows 10 China Get Genuine (Threshold 2, April 2016 Update)", -185), @("Windows 10 Single Language (Threshold 2, April 2016 Update)", 184), - @("Windows 10 N (Threshold 2, April 2016 Update)", 183), - @("Windows 10 KN (Threshold 2, April 2016 Update)", 182), + @("Windows 10 N (Threshold 2, April 2016 Update)", -183), + @("Windows 10 KN (Threshold 2, April 2016 Update)", -182), @("Windows 10 Education N (Threshold 2, April 2016 Update)", 181), - @("Windows 10 Education KN (Threshold 2, April 2016 Update)", 180), + @("Windows 10 Education KN (Threshold 2, April 2016 Update)", -180), @("Windows 10 Education (Threshold 2, April 2016 Update)", 179), @("Windows 10 (Threshold 2, April 2016 Update)", 178) ), @@ -168,10 +162,10 @@ $WindowsVersions = @( "1511 R2 (Build 10586.104 - 2016.02)", @("Windows 10 Single Language (Threshold 2, February 2016 Update)", 116), @("Windows 10 N (Threshold 2, February 2016 Update)", 115), - @("Windows 10 KN (Threshold 2, February 2016 Update)", 114), - @("Windows 10 China Get Genuine (Threshold 2, February 2016 Update)", 113), + @("Windows 10 KN (Threshold 2, February 2016 Update)", -114), + @("Windows 10 China Get Genuine (Threshold 2, February 2016 Update)", -113), @("Windows 10 Education N (Threshold 2, February 2016 Update)", 112), - @("Windows 10 Education KN (Threshold 2, February 2016 Update)", 111), + @("Windows 10 Education KN (Threshold 2, February 2016 Update)", -111), @("Windows 10 Education (Threshold 2, February 2016 Update)", 110), @("Windows 10 (Threshold 2, February 2016 Update)", 109) ), @@ -179,10 +173,10 @@ $WindowsVersions = @( "1511 R1 (Build 10586.0 - 2015.11)", @("Windows 10 Single Language (Threshold 2)", 106), @("Windows 10 N (Threshold 2)", 105), - @("Windows 10 KN (Threshold 2)", 104), - @("Windows 10 China Get Genuine (Threshold 2)", 103), + @("Windows 10 KN (Threshold 2)", -104), + @("Windows 10 China Get Genuine (Threshold 2)", -103), @("Windows 10 Education N (Threshold 2)", 102), - @("Windows 10 Education KN (Threshold 2)", 101), + @("Windows 10 Education KN (Threshold 2)", -101), @("Windows 10 Education (Threshold 2)", 100), @("Windows 10 (Threshold 2)", 99) ), @@ -190,11 +184,11 @@ $WindowsVersions = @( "1507 (Build 10240.16384 - 2015.07)", @("Windows 10 Single Language (Threshold 1)", 82), @("Windows 10 N (Threshold 1)", 81), - @("Windows 10 KN (Threshold 1)", 80), + @("Windows 10 KN (Threshold 1)", -80), @("Windows 10 (Threshold 1)", 79), - @("Windows 10 China Get Genuine (Threshold 1)", 78), + @("Windows 10 China Get Genuine (Threshold 1)", -78), @("Windows 10 Education N (Threshold 1)", 77), - @("Windows 10 Education KN (Threshold 1)", 76), + @("Windows 10 Education KN (Threshold 1)", -76), @("Windows 10 Education (Threshold 1)", 75) ) ), @@ -206,11 +200,11 @@ $WindowsVersions = @( @("Windows 8.1/Windows 8.1 Pro N", 55) @("Windows 8.1 Single Language", 48), @("Windows 8.1 Professional LE N", 71), - @("Windows 8.1 Professional LE KN", 70), - @("Windows 8.1 Professional LE K", 69), + @("Windows 8.1 Professional LE KN", -70), + @("Windows 8.1 Professional LE K", -69), @("Windows 8.1 Professional LE", 68), - @("Windows 8.1 KN", 62), - @("Windows 8.1 K", 61) + @("Windows 8.1 KN", -62), + @("Windows 8.1 K", -61) ) ), @( @@ -221,28 +215,28 @@ $WindowsVersions = @( @("Windows 7 Pro", 4), @("Windows 7 Home Premium", 6), @("Windows 7 Home Basic", 2), - @("Windows 7 Professional KN SP1 COEM", 98), - @("Windows 7 Home Premium KN SP1 COEM", 97), - @("Windows 7 Ultimate SP1 COEM", 96), - @("Windows 7 Ultimate N SP1 COEM", 95), - @("Windows 7 Ultimate KN SP1 COEM", 94), - @("Windows 7 Ultimate K SP1 COEM", 93), - @("Windows 7 Starter SP1 COEM", 92), - @("Windows 7 Professional SP1 COEM", 91), - @("Windows 7 Professional N SP1 COEM", 90), - @("Windows 7 Home Premium K SP1 COEM", 89), - @("Windows 7 Home Premium SP1 COEM GGK", 88), - @("Windows 7 Home Premium SP1 COEM", 87), - @("Windows 7 Home Premium N SP1 COEM", 86), - @("Windows 7 Home Basic SP1 COEM GGK", 85), - @("Windows 7 Home Basic SP1 COEM", 83), + @("Windows 7 Professional KN SP1 COEM", -98), + @("Windows 7 Home Premium KN SP1 COEM", -97), + @("Windows 7 Ultimate SP1 COEM", -96), + @("Windows 7 Ultimate N SP1 COEM", -95), + @("Windows 7 Ultimate KN SP1 COEM", -94), + @("Windows 7 Ultimate K SP1 COEM", -93), + @("Windows 7 Starter SP1 COEM", -92), + @("Windows 7 Professional SP1 COEM", -91), + @("Windows 7 Professional N SP1 COEM", -90), + @("Windows 7 Home Premium K SP1 COEM", -89), + @("Windows 7 Home Premium SP1 COEM GGK", -88), + @("Windows 7 Home Premium SP1 COEM", -87), + @("Windows 7 Home Premium N SP1 COEM", -86), + @("Windows 7 Home Basic SP1 COEM GGK", -85), + @("Windows 7 Home Basic SP1 COEM", -83), @("Windows 7 Starter SP1", 28), - @("Windows 7 Ultimate K SP1", 26), - @("Windows 7 Ultimate KN SP1", 24), - @("Windows 7 Home Premium KN SP1", 22), - @("Windows 7 Home Premium K SP1", 20), - @("Windows 7 Professional KN SP1", 18), - @("Windows 7 Professional K SP1", 16), + @("Windows 7 Ultimate K SP1", -26), + @("Windows 7 Ultimate KN SP1", -24), + @("Windows 7 Home Premium KN SP1", -22), + @("Windows 7 Home Premium K SP1", -20), + @("Windows 7 Professional KN SP1", -18), + @("Windows 7 Professional K SP1", -16), @("Windows 7 Ultimate N SP1", 14), @("Windows 7 Professional N SP1", 12), @("Windows 7 Home Premium N SP1", 10), @@ -256,7 +250,7 @@ $WindowsVersions = @( #endregion #region Functions -function Select-Language([int]$ArrayIndex, [string]$LangName) +function Select-Language([string]$LangName) { # Use the system locale to try select the most appropriate language [string]$SysLocale = [System.Globalization.CultureInfo]::CurrentUICulture.Name @@ -302,9 +296,9 @@ function Select-Language([int]$ArrayIndex, [string]$LangName) ($SysLocale.StartsWith("tr") -and $LangName -like "*Turk*") -or ` ($SysLocale.StartsWith("uk") -and $LangName -like "*Ukrain*") -or ` ($SysLocale.StartsWith("vi") -and $LangName -like "*Vietnam*")) { - return $ArrayIndex + return $True } - return -1 + return $False } function Add-Entry([int]$pos, [string]$Name, [array]$Items, [string]$DisplayName) @@ -434,9 +428,9 @@ function Error([string]$ErrorMessage) #endregion #region Form -[xml]$Form = @" +[xml]$XAML = @" - +