mirror of
https://github.com/pbatard/Fido.git
synced 2025-09-16 14:18:02 +02:00
Don't display special Korean/Chinese versions by default
* Also simplify some of the script
This commit is contained in:
210
Fido.ps1
210
Fido.ps1
@@ -18,14 +18,7 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
# NB: You must have a BOM on your .ps1 if you want Powershell to actually
|
# 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
|
# realise it should use Unicode for the UI rather than 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?
|
|
||||||
|
|
||||||
#region Parameters
|
#region Parameters
|
||||||
param(
|
param(
|
||||||
@@ -33,7 +26,7 @@ param(
|
|||||||
# If not provided, a browser window is opened instead.
|
# If not provided, a browser window is opened instead.
|
||||||
[string]$PipeName,
|
[string]$PipeName,
|
||||||
# (Optional) '|' separated UI localization strings.
|
# (Optional) '|' separated UI localization strings.
|
||||||
[string]$Messages,
|
[string]$LocData,
|
||||||
# (Optional) Path to the file that should be used for the UI icon.
|
# (Optional) Path to the file that should be used for the UI icon.
|
||||||
[string]$Icon,
|
[string]$Icon,
|
||||||
# (Optional) The title to display on the application window
|
# (Optional) The title to display on the application window
|
||||||
@@ -44,6 +37,7 @@ param(
|
|||||||
#region Testing
|
#region Testing
|
||||||
$Debug = $False
|
$Debug = $False
|
||||||
$Testing = $False
|
$Testing = $False
|
||||||
|
$Expert = $False
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
Write-Host Please Wait...
|
Write-Host Please Wait...
|
||||||
@@ -54,10 +48,10 @@ $code = @"
|
|||||||
internal static extern IntPtr LoadLibrary(string lpLibFileName);
|
internal static extern IntPtr LoadLibrary(string lpLibFileName);
|
||||||
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true, BestFitMapping = false, ThrowOnUnmappableChar = true)]
|
[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);
|
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);
|
internal static extern int ExtractIconEx(string sFile, int iIndex, out IntPtr piLargeVersion, out IntPtr piSmallVersion, int amountIcons);
|
||||||
[DllImport("user32.dll")]
|
[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
|
// Returns a localized MUI string from the specified DLL
|
||||||
public static string GetMuiString(string dll, uint index)
|
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 -MemberDefinition $code -Namespace Gui -UsingNamespace "System.IO", "System.Text", "System.Drawing", "System.Globalization" -ReferencedAssemblies System.Drawing -Name Utils -ErrorAction Stop
|
||||||
Add-Type -AssemblyName PresentationFramework
|
Add-Type -AssemblyName PresentationFramework
|
||||||
# Hide the powershell window: https://stackoverflow.com/a/27992426/1069307
|
# 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
|
#endregion
|
||||||
|
|
||||||
#region Data
|
#region Data
|
||||||
@@ -102,51 +96,51 @@ $WindowsVersions = @(
|
|||||||
"1809 R2 (Build 17763.107 - 2018.10)",
|
"1809 R2 (Build 17763.107 - 2018.10)",
|
||||||
@("Windows 10 Home/Pro", 1060),
|
@("Windows 10 Home/Pro", 1060),
|
||||||
@("Windows 10 Education", 1056),
|
@("Windows 10 Education", 1056),
|
||||||
@("Windows 10 Home China ", 1061)
|
@("Windows 10 Home China ", -1061)
|
||||||
),
|
),
|
||||||
@(
|
@(
|
||||||
"1809 R1 (Build 17763.1 - 2018.09)",
|
"1809 R1 (Build 17763.1 - 2018.09)",
|
||||||
@("Windows 10 Home/Pro", 1019),
|
@("Windows 10 Home/Pro", 1019),
|
||||||
@("Windows 10 Education", 1021),
|
@("Windows 10 Education", 1021),
|
||||||
@("Windows 10 Home China ", 1020)
|
@("Windows 10 Home China ", -1020)
|
||||||
),
|
),
|
||||||
@(
|
@(
|
||||||
"1803 (Build 17134.1 - 2018.04)",
|
"1803 (Build 17134.1 - 2018.04)",
|
||||||
@("Windows 10 Home/Pro", 651),
|
@("Windows 10 Home/Pro", 651),
|
||||||
@("Windows 10 Education", 655),
|
@("Windows 10 Education", 655),
|
||||||
@("Windows 10 Enterprise Eval", 629)
|
@("Windows 10 Enterprise Eval", -629)
|
||||||
@("Windows 10 COEM 1803 Home China", 640),
|
@("Windows 10 COEM 1803 Home China", -640),
|
||||||
@("Windows 10 COEM 1803", 639),
|
@("Windows 10 COEM 1803", -639),
|
||||||
@("Windows 10 1803 Home China", 638),
|
@("Windows 10 1803 Home China", -638),
|
||||||
@("Windows 10 1803", 637),
|
@("Windows 10 1803", 637),
|
||||||
@("Windows 10 COEM 1803_1 Home China", 654),
|
@("Windows 10 COEM 1803_1 Home China", -654),
|
||||||
@("Windows 10 COEM 1803_1", 653),
|
@("Windows 10 COEM 1803_1", -653),
|
||||||
@("Windows 10 1803_1 Home China", 652)
|
@("Windows 10 1803_1 Home China", -652)
|
||||||
),
|
),
|
||||||
@(
|
@(
|
||||||
"1709 (Build 16299.15 - 2017.09)",
|
"1709 (Build 16299.15 - 2017.09)",
|
||||||
@("Windows 10 Education 1709", 488),
|
@("Windows 10 Education 1709", 488),
|
||||||
@("Windows 10 COEM 1709 Home China", 487),
|
@("Windows 10 COEM 1709 Home China", -487),
|
||||||
@("Windows 10 COEM 1709", 486),
|
@("Windows 10 COEM 1709", -486),
|
||||||
@("Windows 10 1709 Home China", 485),
|
@("Windows 10 1709 Home China", -485),
|
||||||
@("Windows 10 1709", 484)
|
@("Windows 10 1709", 484)
|
||||||
),
|
),
|
||||||
@(
|
@(
|
||||||
"1703 (Build 15063.0 - 2017.03)",
|
"1703 (Build 15063.0 - 2017.03)",
|
||||||
@("Windows 10 1703 Education N", 424),
|
@("Windows 10 1703 Education N", 424),
|
||||||
@("Windows 10 1703 Education", 423),
|
@("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 Single Language", 371),
|
||||||
@("Windows 10 COEM 1703 N", 370),
|
@("Windows 10 COEM 1703 N", 370),
|
||||||
@("Windows 10 COEM 1703", 369),
|
@("Windows 10 COEM 1703", 369),
|
||||||
@("Windows 10 1703 Home China (Redstone 2)", 364),
|
@("Windows 10 1703 Home China (Redstone 2)", -364),
|
||||||
@("Windows 10 1703 Single Language (Redstone 2)", 363),
|
@("Windows 10 1703 Single Language (Redstone 2)", -363),
|
||||||
@("Windows 10 1703 N (Redstone 2)", 362),
|
@("Windows 10 1703 N (Redstone 2)", 362),
|
||||||
@("Windows 10 1703 (Redstone 2)", 361)
|
@("Windows 10 1703 (Redstone 2)", 361)
|
||||||
),
|
),
|
||||||
@(
|
@(
|
||||||
"1607 (Build 14393.0 - 2017.07)",
|
"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 Single Language (Redstone 1)", 246),
|
||||||
@("Windows 10 N (Redstone 1)", 245),
|
@("Windows 10 N (Redstone 1)", 245),
|
||||||
@("Windows 10 (Redstone 1)", 244),
|
@("Windows 10 (Redstone 1)", 244),
|
||||||
@@ -155,12 +149,12 @@ $WindowsVersions = @(
|
|||||||
),
|
),
|
||||||
@(
|
@(
|
||||||
"1511 R3 (Build 10586.164 - 2016.04)",
|
"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 Single Language (Threshold 2, April 2016 Update)", 184),
|
||||||
@("Windows 10 N (Threshold 2, April 2016 Update)", 183),
|
@("Windows 10 N (Threshold 2, April 2016 Update)", -183),
|
||||||
@("Windows 10 KN (Threshold 2, April 2016 Update)", 182),
|
@("Windows 10 KN (Threshold 2, April 2016 Update)", -182),
|
||||||
@("Windows 10 Education N (Threshold 2, April 2016 Update)", 181),
|
@("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 Education (Threshold 2, April 2016 Update)", 179),
|
||||||
@("Windows 10 (Threshold 2, April 2016 Update)", 178)
|
@("Windows 10 (Threshold 2, April 2016 Update)", 178)
|
||||||
),
|
),
|
||||||
@@ -168,10 +162,10 @@ $WindowsVersions = @(
|
|||||||
"1511 R2 (Build 10586.104 - 2016.02)",
|
"1511 R2 (Build 10586.104 - 2016.02)",
|
||||||
@("Windows 10 Single Language (Threshold 2, February 2016 Update)", 116),
|
@("Windows 10 Single Language (Threshold 2, February 2016 Update)", 116),
|
||||||
@("Windows 10 N (Threshold 2, February 2016 Update)", 115),
|
@("Windows 10 N (Threshold 2, February 2016 Update)", 115),
|
||||||
@("Windows 10 KN (Threshold 2, February 2016 Update)", 114),
|
@("Windows 10 KN (Threshold 2, February 2016 Update)", -114),
|
||||||
@("Windows 10 China Get Genuine (Threshold 2, February 2016 Update)", 113),
|
@("Windows 10 China Get Genuine (Threshold 2, February 2016 Update)", -113),
|
||||||
@("Windows 10 Education N (Threshold 2, February 2016 Update)", 112),
|
@("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 Education (Threshold 2, February 2016 Update)", 110),
|
||||||
@("Windows 10 (Threshold 2, February 2016 Update)", 109)
|
@("Windows 10 (Threshold 2, February 2016 Update)", 109)
|
||||||
),
|
),
|
||||||
@@ -179,10 +173,10 @@ $WindowsVersions = @(
|
|||||||
"1511 R1 (Build 10586.0 - 2015.11)",
|
"1511 R1 (Build 10586.0 - 2015.11)",
|
||||||
@("Windows 10 Single Language (Threshold 2)", 106),
|
@("Windows 10 Single Language (Threshold 2)", 106),
|
||||||
@("Windows 10 N (Threshold 2)", 105),
|
@("Windows 10 N (Threshold 2)", 105),
|
||||||
@("Windows 10 KN (Threshold 2)", 104),
|
@("Windows 10 KN (Threshold 2)", -104),
|
||||||
@("Windows 10 China Get Genuine (Threshold 2)", 103),
|
@("Windows 10 China Get Genuine (Threshold 2)", -103),
|
||||||
@("Windows 10 Education N (Threshold 2)", 102),
|
@("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 Education (Threshold 2)", 100),
|
||||||
@("Windows 10 (Threshold 2)", 99)
|
@("Windows 10 (Threshold 2)", 99)
|
||||||
),
|
),
|
||||||
@@ -190,11 +184,11 @@ $WindowsVersions = @(
|
|||||||
"1507 (Build 10240.16384 - 2015.07)",
|
"1507 (Build 10240.16384 - 2015.07)",
|
||||||
@("Windows 10 Single Language (Threshold 1)", 82),
|
@("Windows 10 Single Language (Threshold 1)", 82),
|
||||||
@("Windows 10 N (Threshold 1)", 81),
|
@("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 (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 N (Threshold 1)", 77),
|
||||||
@("Windows 10 Education KN (Threshold 1)", 76),
|
@("Windows 10 Education KN (Threshold 1)", -76),
|
||||||
@("Windows 10 Education (Threshold 1)", 75)
|
@("Windows 10 Education (Threshold 1)", 75)
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
@@ -206,11 +200,11 @@ $WindowsVersions = @(
|
|||||||
@("Windows 8.1/Windows 8.1 Pro N", 55)
|
@("Windows 8.1/Windows 8.1 Pro N", 55)
|
||||||
@("Windows 8.1 Single Language", 48),
|
@("Windows 8.1 Single Language", 48),
|
||||||
@("Windows 8.1 Professional LE N", 71),
|
@("Windows 8.1 Professional LE N", 71),
|
||||||
@("Windows 8.1 Professional LE KN", 70),
|
@("Windows 8.1 Professional LE KN", -70),
|
||||||
@("Windows 8.1 Professional LE K", 69),
|
@("Windows 8.1 Professional LE K", -69),
|
||||||
@("Windows 8.1 Professional LE", 68),
|
@("Windows 8.1 Professional LE", 68),
|
||||||
@("Windows 8.1 KN", 62),
|
@("Windows 8.1 KN", -62),
|
||||||
@("Windows 8.1 K", 61)
|
@("Windows 8.1 K", -61)
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
@(
|
@(
|
||||||
@@ -221,28 +215,28 @@ $WindowsVersions = @(
|
|||||||
@("Windows 7 Pro", 4),
|
@("Windows 7 Pro", 4),
|
||||||
@("Windows 7 Home Premium", 6),
|
@("Windows 7 Home Premium", 6),
|
||||||
@("Windows 7 Home Basic", 2),
|
@("Windows 7 Home Basic", 2),
|
||||||
@("Windows 7 Professional KN SP1 COEM", 98),
|
@("Windows 7 Professional KN SP1 COEM", -98),
|
||||||
@("Windows 7 Home Premium KN SP1 COEM", 97),
|
@("Windows 7 Home Premium KN SP1 COEM", -97),
|
||||||
@("Windows 7 Ultimate SP1 COEM", 96),
|
@("Windows 7 Ultimate SP1 COEM", -96),
|
||||||
@("Windows 7 Ultimate N SP1 COEM", 95),
|
@("Windows 7 Ultimate N SP1 COEM", -95),
|
||||||
@("Windows 7 Ultimate KN SP1 COEM", 94),
|
@("Windows 7 Ultimate KN SP1 COEM", -94),
|
||||||
@("Windows 7 Ultimate K SP1 COEM", 93),
|
@("Windows 7 Ultimate K SP1 COEM", -93),
|
||||||
@("Windows 7 Starter SP1 COEM", 92),
|
@("Windows 7 Starter SP1 COEM", -92),
|
||||||
@("Windows 7 Professional SP1 COEM", 91),
|
@("Windows 7 Professional SP1 COEM", -91),
|
||||||
@("Windows 7 Professional N SP1 COEM", 90),
|
@("Windows 7 Professional N SP1 COEM", -90),
|
||||||
@("Windows 7 Home Premium K SP1 COEM", 89),
|
@("Windows 7 Home Premium K SP1 COEM", -89),
|
||||||
@("Windows 7 Home Premium SP1 COEM GGK", 88),
|
@("Windows 7 Home Premium SP1 COEM GGK", -88),
|
||||||
@("Windows 7 Home Premium SP1 COEM", 87),
|
@("Windows 7 Home Premium SP1 COEM", -87),
|
||||||
@("Windows 7 Home Premium N SP1 COEM", 86),
|
@("Windows 7 Home Premium N SP1 COEM", -86),
|
||||||
@("Windows 7 Home Basic SP1 COEM GGK", 85),
|
@("Windows 7 Home Basic SP1 COEM GGK", -85),
|
||||||
@("Windows 7 Home Basic SP1 COEM", 83),
|
@("Windows 7 Home Basic SP1 COEM", -83),
|
||||||
@("Windows 7 Starter SP1", 28),
|
@("Windows 7 Starter SP1", 28),
|
||||||
@("Windows 7 Ultimate K SP1", 26),
|
@("Windows 7 Ultimate K SP1", -26),
|
||||||
@("Windows 7 Ultimate KN SP1", 24),
|
@("Windows 7 Ultimate KN SP1", -24),
|
||||||
@("Windows 7 Home Premium KN SP1", 22),
|
@("Windows 7 Home Premium KN SP1", -22),
|
||||||
@("Windows 7 Home Premium K SP1", 20),
|
@("Windows 7 Home Premium K SP1", -20),
|
||||||
@("Windows 7 Professional KN SP1", 18),
|
@("Windows 7 Professional KN SP1", -18),
|
||||||
@("Windows 7 Professional K SP1", 16),
|
@("Windows 7 Professional K SP1", -16),
|
||||||
@("Windows 7 Ultimate N SP1", 14),
|
@("Windows 7 Ultimate N SP1", 14),
|
||||||
@("Windows 7 Professional N SP1", 12),
|
@("Windows 7 Professional N SP1", 12),
|
||||||
@("Windows 7 Home Premium N SP1", 10),
|
@("Windows 7 Home Premium N SP1", 10),
|
||||||
@@ -256,7 +250,7 @@ $WindowsVersions = @(
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Functions
|
#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
|
# Use the system locale to try select the most appropriate language
|
||||||
[string]$SysLocale = [System.Globalization.CultureInfo]::CurrentUICulture.Name
|
[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("tr") -and $LangName -like "*Turk*") -or `
|
||||||
($SysLocale.StartsWith("uk") -and $LangName -like "*Ukrain*") -or `
|
($SysLocale.StartsWith("uk") -and $LangName -like "*Ukrain*") -or `
|
||||||
($SysLocale.StartsWith("vi") -and $LangName -like "*Vietnam*")) {
|
($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)
|
function Add-Entry([int]$pos, [string]$Name, [array]$Items, [string]$DisplayName)
|
||||||
@@ -434,9 +428,9 @@ function Error([string]$ErrorMessage)
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Form
|
#region Form
|
||||||
[xml]$Form = @"
|
[xml]$XAML = @"
|
||||||
<Window xmlns = "http://schemas.microsoft.com/winfx/2006/xaml/presentation" Height = "162" Width = "384" ResizeMode = "NoResize">
|
<Window xmlns = "http://schemas.microsoft.com/winfx/2006/xaml/presentation" Height = "162" Width = "384" ResizeMode = "NoResize">
|
||||||
<Grid Name = "Grid">
|
<Grid Name = "XMLGrid">
|
||||||
<Button Name = "Confirm" FontSize = "16" Height = "26" Width = "160" HorizontalAlignment = "Left" VerticalAlignment = "Top" Margin = "14,78,0,0"/>
|
<Button Name = "Confirm" FontSize = "16" Height = "26" Width = "160" HorizontalAlignment = "Left" VerticalAlignment = "Top" Margin = "14,78,0,0"/>
|
||||||
<Button Name = "Back" FontSize = "16" Height = "26" Width = "160" HorizontalAlignment = "Left" VerticalAlignment = "Top" Margin = "194,78,0,0"/>
|
<Button Name = "Back" FontSize = "16" Height = "26" Width = "160" HorizontalAlignment = "Left" VerticalAlignment = "Top" Margin = "194,78,0,0"/>
|
||||||
<TextBlock Name = "WindowsVersionTitle" FontSize = "16" Width="340" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="16,8,0,0"/>
|
<TextBlock Name = "WindowsVersionTitle" FontSize = "16" Width="340" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="16,8,0,0"/>
|
||||||
@@ -461,9 +455,9 @@ $RequestData["GetLinks"] = @("cfa9e580-a81e-4a4b-a846-7b21bf4e2e5b", "GetProduct
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
# Localization
|
# Localization
|
||||||
$EnglishMessages = "en-US|Version|Release|Edition|Language|Architecture|Download|Confirm|Change|Close|Cancel|Error"
|
$EnglishMessages = "en-US|Version|Release|Edition|Language|Architecture|Download|Confirm|Back|Close|Error|Please wait..."
|
||||||
if ($Testing) {
|
if ($Testing) {
|
||||||
$Messages = "fr-FR|||Édition|Langue de produit||Télécharger|Confirmer|Changer|Fermer|Abandonner|Erreur"
|
$LocData = "fr-FR|||Édition|Langue de produit||Télécharger|Confirmer|Retour|Fermer|Erreur|Veuillez patienter..."
|
||||||
$TestLangs = '{"languages":[
|
$TestLangs = '{"languages":[
|
||||||
{ "language":"English", "text":"Anglais", "id":"100" },
|
{ "language":"English", "text":"Anglais", "id":"100" },
|
||||||
{ "language":"English (International)", "text":"Anglais (International)", "id":"101" },
|
{ "language":"English (International)", "text":"Anglais (International)", "id":"101" },
|
||||||
@@ -473,18 +467,18 @@ if ($Testing) {
|
|||||||
}
|
}
|
||||||
[string[]]$English = $EnglishMessages.Split('|')
|
[string[]]$English = $EnglishMessages.Split('|')
|
||||||
[string[]]$Localized = $null
|
[string[]]$Localized = $null
|
||||||
if ($Messages) {
|
if ($LocData -and (-not $LocData.StartsWith("en-US"))) {
|
||||||
$Localized = $Messages.Split('|')
|
$Localized = $LocData.Split('|')
|
||||||
if ($Localized.Length -ne $English.Length) {
|
if ($Localized.Length -ne $English.Length) {
|
||||||
Write-Host Error: Missing or extra translated messages provided
|
Write-Host "Error: Missing or extra translated messages provided ($($Localized.Length)/$($English.Length))"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
$Locale = $Localized[0]
|
$Locale = $Localized[0]
|
||||||
}
|
}
|
||||||
|
|
||||||
# Form creation
|
# Form creation
|
||||||
$XMLReader = New-Object System.Xml.XmlNodeReader $Form
|
$XMLForm = [Windows.Markup.XamlReader]::Load((New-Object System.Xml.XmlNodeReader $XAML))
|
||||||
$XMLForm = [Windows.Markup.XamlReader]::Load($XMLReader)
|
$XAML.SelectNodes("//*[@Name]") | ForEach-Object { Set-Variable -Name ($_.Name) -Value $XMLForm.FindName($_.Name) -Scope Script }
|
||||||
$XMLForm.Title = $AppTitle
|
$XMLForm.Title = $AppTitle
|
||||||
if ($Icon) {
|
if ($Icon) {
|
||||||
$XMLForm.Icon = $Icon
|
$XMLForm.Icon = $Icon
|
||||||
@@ -494,18 +488,12 @@ if ($Icon) {
|
|||||||
if ($Locale.StartsWith("ar") -or $Locale.StartsWith("fa") -or $Locale.StartsWith("he")) {
|
if ($Locale.StartsWith("ar") -or $Locale.StartsWith("fa") -or $Locale.StartsWith("he")) {
|
||||||
$XMLForm.FlowDirection = "RightToLeft"
|
$XMLForm.FlowDirection = "RightToLeft"
|
||||||
}
|
}
|
||||||
$XMLGrid = $XMLForm.FindName("Grid")
|
$WindowsVersionTitle.Text = Get-Translation("Version")
|
||||||
$Confirm = $XMLForm.FindName("Confirm")
|
|
||||||
$Confirm.Content = Get-Translation("Confirm")
|
$Confirm.Content = Get-Translation("Confirm")
|
||||||
$Back = $XMLForm.FindName("Back")
|
$Back.Content = Get-Translation("Back")
|
||||||
$Back.Content = Get-Translation("Change")
|
|
||||||
$Back.IsEnabled = $False
|
$Back.IsEnabled = $False
|
||||||
|
|
||||||
# Populate in the Windows Version dropdown
|
# Populate the Windows versions
|
||||||
$WindowsVersionTitle = $XMLForm.FindName("WindowsVersionTitle")
|
|
||||||
$WindowsVersionTitle.Text = Get-Translation("Version")
|
|
||||||
$WindowsVersion = $XMLForm.FindName("WindowsVersion")
|
|
||||||
|
|
||||||
$i = 0
|
$i = 0
|
||||||
$array = @()
|
$array = @()
|
||||||
foreach($Version in $WindowsVersions) {
|
foreach($Version in $WindowsVersions) {
|
||||||
@@ -531,7 +519,7 @@ $Confirm.add_click({
|
|||||||
switch ($Stage) {
|
switch ($Stage) {
|
||||||
|
|
||||||
1 { # Windows Version selection => Get a Session ID and populate Windows Release
|
1 { # Windows Version selection => Get a Session ID and populate Windows Release
|
||||||
$XMLForm.Title = "Querying Microsoft download servers..."
|
$XMLForm.Title = Get-Translation("Please wait...")
|
||||||
Refresh-Control($XMLForm)
|
Refresh-Control($XMLForm)
|
||||||
|
|
||||||
$url = "https://www.microsoft.com/" + $Locale + "/software-download/windows10ISO/"
|
$url = "https://www.microsoft.com/" + $Locale + "/software-download/windows10ISO/"
|
||||||
@@ -572,7 +560,9 @@ $Confirm.add_click({
|
|||||||
foreach ($Release in $WindowsVersions[$WindowsVersion.SelectedValue.Index][$WindowsRelease.SelectedValue.Index])
|
foreach ($Release in $WindowsVersions[$WindowsVersion.SelectedValue.Index][$WindowsRelease.SelectedValue.Index])
|
||||||
{
|
{
|
||||||
if ($Release -is [array]) {
|
if ($Release -is [array]) {
|
||||||
$array += @(New-Object PsObject -Property @{ Edition = $Release[0]; Id = $Release[1] })
|
if ($Expert -or ($Release[1] -ge 0)) {
|
||||||
|
$array += @(New-Object PsObject -Property @{ Edition = $Release[0]; Id = $Release[1] })
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$script:ProductEdition = Add-Entry $Stage "Edition" $array
|
$script:ProductEdition = Add-Entry $Stage "Edition" $array
|
||||||
@@ -587,12 +577,13 @@ $Confirm.add_click({
|
|||||||
$url += "&segments=software-download," + $PageType
|
$url += "&segments=software-download," + $PageType
|
||||||
$url += "&query=&action=" + $RequestData["GetLangs"][1]
|
$url += "&query=&action=" + $RequestData["GetLangs"][1]
|
||||||
$url += "&sessionId=" + $SessionId
|
$url += "&sessionId=" + $SessionId
|
||||||
$url += "&productEditionId=" + $ProductEdition.SelectedValue.Id
|
$url += "&productEditionId=" + [Math]::Abs($ProductEdition.SelectedValue.Id)
|
||||||
$url += "&sdVersion=2"
|
$url += "&sdVersion=2"
|
||||||
Write-Host Querying $url
|
Write-Host Querying $url
|
||||||
|
|
||||||
$array = @()
|
$array = @()
|
||||||
$index = 0
|
$i = 0
|
||||||
|
$SelectedIndex = 0
|
||||||
if (-not $Testing) {
|
if (-not $Testing) {
|
||||||
try {
|
try {
|
||||||
$r = Invoke-WebRequest -WebSession $Session $url
|
$r = Invoke-WebRequest -WebSession $Session $url
|
||||||
@@ -603,11 +594,10 @@ $Confirm.add_click({
|
|||||||
$json = $var.value | ConvertFrom-Json;
|
$json = $var.value | ConvertFrom-Json;
|
||||||
if ($json) {
|
if ($json) {
|
||||||
$array += @(New-Object PsObject -Property @{ DisplayLanguage = $var.text; Language = $json.language; Id = $json.id })
|
$array += @(New-Object PsObject -Property @{ DisplayLanguage = $var.text; Language = $json.language; Id = $json.id })
|
||||||
$s = Select-Language -ArrayIndex $index -LangName $json.language
|
if (Select-Language($json.language)) {
|
||||||
if ($s -ge 0) {
|
$SelectedIndex = $i
|
||||||
$Language.SelectedIndex = $s
|
|
||||||
}
|
}
|
||||||
$index++
|
$i++
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($array.Length -eq 0) {
|
if ($array.Length -eq 0) {
|
||||||
@@ -624,14 +614,14 @@ $Confirm.add_click({
|
|||||||
} else {
|
} else {
|
||||||
foreach ($var in $(ConvertFrom-Json –InputObject $TestLangs).languages) {
|
foreach ($var in $(ConvertFrom-Json –InputObject $TestLangs).languages) {
|
||||||
$array += @(New-Object PsObject -Property @{ DisplayLanguage = $var.text; Language = $var.language; Id = $var.id })
|
$array += @(New-Object PsObject -Property @{ DisplayLanguage = $var.text; Language = $var.language; Id = $var.id })
|
||||||
$s = Select-Language -ArrayIndex $index -LangName $var.language
|
if (Select-Language($var.language)) {
|
||||||
if ($s -ge 0) {
|
$SelectedIndex = $i
|
||||||
$Language.SelectedIndex = $s
|
|
||||||
}
|
}
|
||||||
$index++
|
$i++
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$script:Language = Add-Entry $Stage "Language" $array "DisplayLanguage"
|
$script:Language = Add-Entry $Stage "Language" $array "DisplayLanguage"
|
||||||
|
$Language.SelectedIndex = $SelectedIndex
|
||||||
}
|
}
|
||||||
|
|
||||||
4 { # Language selection => Request and populate Arch download links
|
4 { # Language selection => Request and populate Arch download links
|
||||||
@@ -646,7 +636,8 @@ $Confirm.add_click({
|
|||||||
$url += "&sdVersion=2"
|
$url += "&sdVersion=2"
|
||||||
Write-Host Querying $url
|
Write-Host Querying $url
|
||||||
|
|
||||||
$index = 0
|
$i = 0
|
||||||
|
$SelectedIndex = 0
|
||||||
$array = @()
|
$array = @()
|
||||||
if (-not $Testing) {
|
if (-not $Testing) {
|
||||||
try {
|
try {
|
||||||
@@ -658,26 +649,26 @@ $Confirm.add_click({
|
|||||||
if ($Type -like "*arm64*") {
|
if ($Type -like "*arm64*") {
|
||||||
$Type = "Arm64"
|
$Type = "Arm64"
|
||||||
if ($ENV:PROCESSOR_ARCHITECTURE -eq "ARM64") {
|
if ($ENV:PROCESSOR_ARCHITECTURE -eq "ARM64") {
|
||||||
$Arch.SelectedIndex = $index
|
$SelectedIndex = $i
|
||||||
}
|
}
|
||||||
} elseif ($Type -like "*arm*") {
|
} elseif ($Type -like "*arm*") {
|
||||||
$Type = "Arm"
|
$Type = "Arm"
|
||||||
if ($ENV:PROCESSOR_ARCHITECTURE -eq "ARM") {
|
if ($ENV:PROCESSOR_ARCHITECTURE -eq "ARM") {
|
||||||
$Arch.SelectedIndex = $index
|
$SelectedIndex = $i
|
||||||
}
|
}
|
||||||
} elseif ($Type -like "*x64*") {
|
} elseif ($Type -like "*x64*") {
|
||||||
$Type = "x64"
|
$Type = "x64"
|
||||||
if ($ENV:PROCESSOR_ARCHITECTURE -eq "AMD64") {
|
if ($ENV:PROCESSOR_ARCHITECTURE -eq "AMD64") {
|
||||||
$Arch.SelectedIndex = $index
|
$SelectedIndex = $i
|
||||||
}
|
}
|
||||||
} elseif ($Type -like "*x86*") {
|
} elseif ($Type -like "*x86*") {
|
||||||
$Type = "x86"
|
$Type = "x86"
|
||||||
if ($ENV:PROCESSOR_ARCHITECTURE -eq "X86") {
|
if ($ENV:PROCESSOR_ARCHITECTURE -eq "X86") {
|
||||||
$Arch.SelectedIndex = $index
|
$SelectedIndex = $i
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$array += @(New-Object PsObject -Property @{ Type = $Type; Link = $Link })
|
$array += @(New-Object PsObject -Property @{ Type = $Type; Link = $Link })
|
||||||
$index++
|
$i++
|
||||||
}
|
}
|
||||||
if ($array.Length -eq 0) {
|
if ($array.Length -eq 0) {
|
||||||
$ErrorMessage = $r.ParsedHtml.IHTMLDocument3_GetElementByID("errorModalMessage").innerHtml
|
$ErrorMessage = $r.ParsedHtml.IHTMLDocument3_GetElementByID("errorModalMessage").innerHtml
|
||||||
@@ -692,14 +683,15 @@ $Confirm.add_click({
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$array += @(New-Object PsObject -Property @{ Type = "x86"; Link = "https://rufus.ie" })
|
$array += @(New-Object PsObject -Property @{ Type = "x86"; Link = "https://rufus.ie" })
|
||||||
$index++
|
$i++
|
||||||
$array += @(New-Object PsObject -Property @{ Type = "x64"; Link = "https://rufus.ie" })
|
$array += @(New-Object PsObject -Property @{ Type = "x64"; Link = "https://rufus.ie" })
|
||||||
if ($ENV:PROCESSOR_ARCHITECTURE -eq "AMD64") {
|
if ($ENV:PROCESSOR_ARCHITECTURE -eq "AMD64") {
|
||||||
$Arch.SelectedIndex = $index
|
$SelectedIndex = $i
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$script:Arch = Add-Entry $Stage "Architecture" $array "Type"
|
$script:Arch = Add-Entry $Stage "Architecture" $array "Type"
|
||||||
|
$Arch.SelectedIndex = $SelectedIndex
|
||||||
$Confirm.Content = Get-Translation("Download")
|
$Confirm.Content = Get-Translation("Download")
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -745,7 +737,7 @@ $ClosePrompt = {
|
|||||||
param($PromptTitle)
|
param($PromptTitle)
|
||||||
while ($True) {
|
while ($True) {
|
||||||
Get-Process | Where-Object { $_.MainWindowTitle -match $PromptTitle } | ForEach-Object { $_.CloseMainWindow() }
|
Get-Process | Where-Object { $_.MainWindowTitle -match $PromptTitle } | ForEach-Object { $_.CloseMainWindow() }
|
||||||
Start-Sleep -Milliseconds 200
|
Start-Sleep -Milliseconds 100
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
# Get the localized version of the 'Windows Security Warning' title of the cookie prompt
|
# Get the localized version of the 'Windows Security Warning' title of the cookie prompt
|
||||||
@@ -756,7 +748,7 @@ if (-not $SecurityWarningTitle) {
|
|||||||
$Job = Start-Job -ScriptBlock $ClosePrompt -ArgumentList $SecurityWarningTitle
|
$Job = Start-Job -ScriptBlock $ClosePrompt -ArgumentList $SecurityWarningTitle
|
||||||
|
|
||||||
# Display the dialog
|
# Display the dialog
|
||||||
$null = $XMLForm.ShowDialog()
|
$XMLForm.ShowDialog() | Out-Null
|
||||||
|
|
||||||
# Clean up & exit
|
# Clean up & exit
|
||||||
Stop-Job -Job $Job
|
Stop-Job -Job $Job
|
||||||
|
Reference in New Issue
Block a user