Browse Source

WSL function re-written

pull/450/head
Dmitry Nefedov 2 years ago
parent
commit
7574dc96d1
  1. 2
      Wrapper/Config/config_Windows_10.json
  2. 2
      Wrapper/Config/config_Windows_10_LTSC.json
  3. 2
      Wrapper/Config/config_Windows_11.json
  4. 2
      Wrapper/Localizations/de-DE/tooltip_Windows_10.json
  5. 2
      Wrapper/Localizations/de-DE/tooltip_Windows_11.json
  6. 2
      Wrapper/Localizations/en-US/tooltip_Windows_10.json
  7. 2
      Wrapper/Localizations/en-US/tooltip_Windows_11.json
  8. 2
      Wrapper/Localizations/ru-RU/tooltip_Windows_10.json
  9. 2
      Wrapper/Localizations/ru-RU/tooltip_Windows_11.json
  10. 119
      src/Sophia_Script_for_Windows_10/Module/Sophia.psm1
  11. 8
      src/Sophia_Script_for_Windows_10/Sophia.ps1
  12. 4
      src/Sophia_Script_for_Windows_10_LTSC_2021/Module/Sophia.psm1
  13. 2
      src/Sophia_Script_for_Windows_10_LTSC_2021/Sophia.ps1
  14. 119
      src/Sophia_Script_for_Windows_10_PowerShell_7/Module/Sophia.psm1
  15. 8
      src/Sophia_Script_for_Windows_10_PowerShell_7/Sophia.ps1
  16. 124
      src/Sophia_Script_for_Windows_11/Module/Sophia.psm1
  17. 6
      src/Sophia_Script_for_Windows_11/Sophia.ps1
  18. 118
      src/Sophia_Script_for_Windows_11_PowerShell_7/Module/Sophia.psm1
  19. 6
      src/Sophia_Script_for_Windows_11_PowerShell_7/Sophia.ps1

2
Wrapper/Config/config_Windows_10.json

@ -1832,7 +1832,7 @@
"Region": "UWP apps",
"Control": "cmb",
"Required": "false",
"Function": "HEIF",
"Function": "HEVC",
"Arg": {
"Zero": {
"Tag": "Manually"

2
Wrapper/Config/config_Windows_10_LTSC.json

@ -2020,7 +2020,7 @@
"Region": "UWP apps",
"Control": "cmb",
"Required": "false",
"Function": "HEIF",
"Function": "HEVC",
"Arg": {
"Zero": {
"Tag": "Manually"

2
Wrapper/Config/config_Windows_11.json

@ -1692,7 +1692,7 @@
"Region": "UWP apps",
"Control": "cmb",
"Required": "false",
"Function": "HEIF",
"Function": "HEVC",
"Arg": {
"Zero": {
"Tag": "Manually"

2
Wrapper/Localizations/de-DE/tooltip_Windows_10.json

@ -1627,7 +1627,7 @@
{
"Id": 803,
"Region": "UWP apps",
"Function": "HEIF",
"Function": "HEVC",
"Arg": {
"Zero": {
"Tag": "Manually",

2
Wrapper/Localizations/de-DE/tooltip_Windows_11.json

@ -1502,7 +1502,7 @@
{
"Id": 803,
"Region": "UWP apps",
"Function": "HEIF",
"Function": "HEVC",
"Arg": {
"Zero": {
"Tag": "Manually",

2
Wrapper/Localizations/en-US/tooltip_Windows_10.json

@ -1627,7 +1627,7 @@
{
"Id": 803,
"Region": "UWP apps",
"Function": "HEIF",
"Function": "HEVC",
"Arg": {
"Zero": {
"Tag": "Manually",

2
Wrapper/Localizations/en-US/tooltip_Windows_11.json

@ -1502,7 +1502,7 @@
{
"Id": 803,
"Region": "UWP apps",
"Function": "HEIF",
"Function": "HEVC",
"Arg": {
"Zero": {
"Tag": "Manually",

2
Wrapper/Localizations/ru-RU/tooltip_Windows_10.json

@ -1627,7 +1627,7 @@
{
"Id": 803,
"Region": "UWP apps",
"Function": "HEIF",
"Function": "HEVC",
"Arg": {
"Zero": {
"Tag": "Manually",

2
Wrapper/Localizations/ru-RU/tooltip_Windows_11.json

@ -1502,7 +1502,7 @@
{
"Id": 803,
"Region": "UWP apps",
"Function": "HEIF",
"Function": "HEVC",
"Arg": {
"Zero": {
"Tag": "Manually",

119
src/Sophia_Script_for_Windows_10/Module/Sophia.psm1

@ -4451,7 +4451,7 @@ function OneDrive
$UserEmail = Get-ItemProperty -Path HKCU:\Software\Microsoft\OneDrive\Accounts\Personal -Name UserEmail -ErrorAction Ignore
if ($PresetName -and $UserEmail)
{
# Exit if user accidentelly set function in preset to uninstall but he's logged into the app
# Exit if user accidentally set function in preset to uninstall but he's logged into the app
return
}
@ -9280,8 +9280,12 @@ function InstallVCRedist
if ([System.Version](Get-AppxPackage -Name Microsoft.DesktopAppInstaller -ErrorAction Ignore).Version -ge [System.Version]"1.17")
{
# https://github.com/microsoft/winget-pkgs/tree/master/manifests/m/Microsoft/VCRedist/2015%2B
winget install --id=Microsoft.VCRedist.2015+.x86 --exact --accept-source-agreements
winget install --id=Microsoft.VCRedist.2015+.x64 --exact --accept-source-agreements
# PowerShell 5.1 (7.3 too) interprets 8.3 file name literally, if an environment variable contains a non-latin word
Get-ChildItem -Path "$env:TEMP\WinGet" -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
}
else
{
@ -9311,8 +9315,7 @@ function InstallVCRedist
"$DownloadsFolder\VC_redist.x86.exe",
"$DownloadsFolder\VC_redist.x64.exe",
"$env:TEMP\dd_vcredist_x86_*.log",
"$env:TEMP\dd_vcredist_amd64_*.log",
"$env:TEMP\WinGet"
"$env:TEMP\dd_vcredist_amd64_*.log"
)
Get-ChildItem -Path $Paths -Recurse -Force | Remove-Item -Recurse -Force -ErrorAction Ignore
}
@ -9357,15 +9360,20 @@ function InstallDotNetRuntimes
if ([System.Version](Get-AppxPackage -Name Microsoft.DesktopAppInstaller -ErrorAction Ignore).Version -ge [System.Version]"1.17")
{
# https://github.com/microsoft/winget-pkgs/tree/master/manifests/m/Microsoft/DotNet/DesktopRuntime/6
# .NET Desktop Runtime 6 x86
winget install --id=Microsoft.DotNet.DesktopRuntime.6 --architecture x86 --exact --accept-source-agreements
# .NET Desktop Runtime 7 x64
# .NET Desktop Runtime 6 x64
winget install --id=Microsoft.DotNet.DesktopRuntime.6 --architecture x64 --exact --accept-source-agreements
# https://github.com/microsoft/winget-pkgs/tree/master/manifests/m/Microsoft/DotNet/DesktopRuntime/7
# .NET Desktop Runtime 7 x86
winget install --id=Microsoft.DotNet.DesktopRuntime.7 --architecture x86 --exact --accept-source-agreements
# .NET Desktop Runtime 7 x64
winget install --id=Microsoft.DotNet.DesktopRuntime.7 --architecture x64 --exact --accept-source-agreements
# PowerShell 5.1 (7.3 too) interprets 8.3 file name literally, if an environment variable contains a non-latin word
Get-ChildItem -Path "$env:TEMP\WinGet" -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
}
else
{
@ -9631,11 +9639,11 @@ function PreventEdgeShortcutCreation
.SYNOPSIS
Windows Subsystem for Linux (WSL)
.PARAMETER Install
.PARAMETER
Enable Windows Subsystem for Linux (WSL), install the latest WSL Linux kernel version, and a Linux distribution using a pop-up form
.EXAMPLE
WSL
Install-WSL
.NOTES
The "Receive updates for other Microsoft products" setting will be enabled automatically to receive kernel updates
@ -9643,8 +9651,17 @@ function PreventEdgeShortcutCreation
.NOTES
Machine-wide
#>
function WSL
function Install-WSL
{
[System.Console]::OutputEncoding = [System.Text.Encoding]::Unicode
$Distros = (wsl --list --online | Select-Object -Skip 8).Replace(" ", "").Replace("* ", "") | ForEach-Object -Process {
[PSCustomObject]@{
"Distro" = $_ -split " ", 2 | Select-Object -Last 1
"Alias" = $_ -split " ", 2 | Select-Object -First 1
}
}
Add-Type -AssemblyName PresentationCore, PresentationFramework
#region Variables
@ -9658,19 +9675,12 @@ function WSL
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Name="Window"
Title="WSL"
MinHeight="400" MinWidth="350"
MinHeight="460" MinWidth="350"
SizeToContent="WidthAndHeight" WindowStartupLocation="CenterScreen"
TextOptions.TextFormattingMode="Display" SnapsToDevicePixels="True"
FontFamily="Candara" FontSize="16" ShowInTaskbar="True"
Background="#F1F1F1" Foreground="#262626">
<Window.Resources>
<Style TargetType="StackPanel" x:Key="PanelContainerStyle">
<Setter Property="Grid.Row" Value="0"/>
<Setter Property="Orientation" Value="Vertical"/>
</Style>
<Style TargetType="StackPanel" x:Key="PanelElementStyle">
<Setter Property="Orientation" Value="Horizontal"/>
</Style>
<Style TargetType="RadioButton">
<Setter Property="VerticalAlignment" Value="Center"/>
<Setter Property="Margin" Value="10"/>
@ -9690,47 +9700,7 @@ function WSL
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<StackPanel Name="PanelContainer" Style="{StaticResource PanelContainerStyle}">
<StackPanel Style="{StaticResource PanelElementStyle}">
<RadioButton Name="RadioButtonUbuntu" GroupName="NixNames" Tag="Ubuntu"/>
<TextBlock Text="Ubuntu"/>
</StackPanel>
<StackPanel Style="{StaticResource PanelElementStyle}">
<RadioButton Name="RadioButtonDebian" GroupName="NixNames" Tag="Debian"/>
<TextBlock Text="Debian GNU/Linux"/>
</StackPanel>
<StackPanel Style="{StaticResource PanelElementStyle}">
<RadioButton Name="RadioButtonKali" GroupName="NixNames" Tag="kali-linux"/>
<TextBlock Text="Kali Linux Rolling"/>
</StackPanel>
<StackPanel Style="{StaticResource PanelElementStyle}">
<RadioButton Name="RadioButtonOpenSuse" GroupName="NixNames" Tag="openSUSE-42"/>
<TextBlock Text="openSUSE Leap 42"/>
</StackPanel>
<StackPanel Style="{StaticResource PanelElementStyle}">
<RadioButton Name="RadioButtonSuse" GroupName="NixNames" Tag="SLES-12"/>
<TextBlock Text="SUSE Linux Enterprise Server v12"/>
</StackPanel>
<StackPanel Style="{StaticResource PanelElementStyle}">
<RadioButton Name="RadioButtonUbuntu16" GroupName="NixNames" Tag="Ubuntu-16.04"/>
<TextBlock Text="Ubuntu 16.04 LTS"/>
</StackPanel>
<StackPanel Style="{StaticResource PanelElementStyle}">
<RadioButton Name="RadioButtonUbuntu18" GroupName="NixNames" Tag="Ubuntu-18.04"/>
<TextBlock Text="Ubuntu 18.04 LTS"/>
</StackPanel>
<StackPanel Style="{StaticResource PanelElementStyle}">
<RadioButton Name="RadioButtonUbuntu20" GroupName="NixNames" Tag="Ubuntu-20.04"/>
<TextBlock Text="Ubuntu 20.04 LTS"/>
</StackPanel>
</StackPanel>
<StackPanel Name="PanelContainer" Grid.Row="0"/>
<Button Name="ButtonInstall" Content="Install" Grid.Row="2"/>
</Grid>
</Window>
@ -9749,7 +9719,11 @@ function WSL
function ButtonInstallClicked
{
Write-Warning -Message $Script:CommandTag
Start-Process -FilePath wsl.exe -ArgumentList "--install --distribution $Script:CommandTag" -Wait
$Form.Close()
}
#endregion
@ -9757,11 +9731,23 @@ function WSL
$XAML.SelectNodes("//*[@*[contains(translate(name(.),'n','N'),'Name')]]") | ForEach-Object -Process {
$control = $Form.FindName($_.Name)
Set-Variable -Name ($_.Name) -Value $control
if ($Control.Template.TargetType.Name -eq "RadioButton")
{
$Control.add_Checked({RadioButtonChecked})
}
}
foreach ($Distro in $Distros)
{
$Panel = New-Object -TypeName System.Windows.Controls.StackPanel
$RadioButton = New-Object -TypeName System.Windows.Controls.RadioButton
$TextBlock = New-Object -TypeName System.Windows.Controls.TextBlock
$Panel.Orientation = "Horizontal"
$RadioButton.GroupName = "WslDistro"
$RadioButton.Tag = $Distro.Alias
$RadioButton.add_Checked({RadioButtonChecked})
$TextBlock.Text = $Distro.Distro
$Panel.Children.Add($RadioButton) | Out-Null
$Panel.Children.Add($TextBlock) | Out-Null
$PanelContainer.Children.Add($Panel) | Out-Null
}
$ButtonInstall.add_Click({ButtonInstallClicked})
#region Sendkey function
@ -9789,7 +9775,7 @@ public static extern bool SetForegroundWindow(IntPtr hWnd);
Add-Type @SetForegroundWindow
}
Get-Process | Where-Object -FilterScript {(($_.ProcessName -eq "powershell") -or ($_.ProcessName -eq "WindowsTerminal")) -and ($_.MainWindowTitle -match "Sophia Script for Windows 10")} | ForEach-Object -Process {
Get-Process | Where-Object -FilterScript {(($_.ProcessName -eq "powershell") -or ($_.ProcessName -eq "WindowsTerminal")) -and ($_.MainWindowTitle -match "Sophia Script for Windows 11")} | ForEach-Object -Process {
# Show window, if minimized
[WinAPI.ForegroundWindow]::ShowWindowAsync($_.MainWindowHandle, 10)
@ -9811,6 +9797,9 @@ public static extern bool SetForegroundWindow(IntPtr hWnd);
# Receive updates for other Microsoft products when you update Windows
(New-Object -ComObject Microsoft.Update.ServiceManager).AddService2("7971f918-a847-4430-9279-4a52d1efe18d", 7, "")
# Trigger Windows Update for detecting new updates
(New-Object -ComObject Microsoft.Update.AutoUpdate).DetectNow()
}
#endregion WSL
@ -10378,7 +10367,7 @@ function UninstallUWPApps
# HEVC Video Extensions from Device Manufacturer
"Microsoft.HEVCVideoExtension",
# HEIF Image Extensions
# HEVC Image Extensions
"Microsoft.HEIFImageExtension",
# MPEG-2 Video Extension
@ -11054,10 +11043,10 @@ public static extern bool SetForegroundWindow(IntPtr hWnd);
Open Microsoft Store "HEVC Video Extensions from Device Manufacturer" page to install the extension manually
.EXAMPLE
HEIF -Install
HEVC -Install
.EXAMPLE
HEIF -Manually
HEVC -Manually
.LINK
https://www.microsoft.com/store/productId/9n4wgh0z6vhq
@ -11071,7 +11060,7 @@ public static extern bool SetForegroundWindow(IntPtr hWnd);
.NOTES
Current user
#>
function HEIF
function HEVC
{
param
(

8
src/Sophia_Script_for_Windows_10/Sophia.ps1

@ -27,7 +27,7 @@
.NOTES
Supported Windows 10 versions
Versions: 21H2/22H2
Builds: 1904x.2364+
Builds: 19044.2364+
Editions: Home/Pro/Enterprise
Architecture: x64
@ -1012,7 +1012,7 @@ PreventEdgeShortcutCreation -Channels Stable, Beta, Dev, Canary
Установить подсистему Windows для Linux (WSL), последний пакет обновления ядра Linux и дистрибутив Linux, используя всплывающую форму
Параметр "При обновлении Windows получать обновления для других продуктов Майкрософт" будет включен автоматически в Центре обновлении Windows, чтобы получать обновления ядра
#>
# WSL
# Install-WSL
#endregion WSL
#region Start menu
@ -1081,7 +1081,7 @@ UninstallUWPApps
# Download and install "HEVC Video Extensions from Device Manufacturer" to be able to open .heic and .heif formats
# Скачать и установить "Расширения для видео HEVC от производителя устройства", чтобы иметь возможность открывать форматы .heic и .heif
HEIF -Install
HEVC -Install
<#
Open Microsoft Store "HEVC Video Extensions from Device Manufacturer" page to install this extension manually to be able to open .heic and .heif formats
@ -1090,7 +1090,7 @@ HEIF -Install
Открыть страницу "Расширения для видео HEVC от производителя устройства" в Microsoft Store, чтобы вручную установить расширение для открытия форматов .heic и .heif
Расширение может быть установлено бесплатно без учетной записи Microsoft
#>
# HEIF -Manually
# HEVC -Manually
# Disable Cortana autostarting
# Выключить автозагрузку Кортана

4
src/Sophia_Script_for_Windows_10_LTSC_2021/Module/Sophia.psm1

@ -8563,7 +8563,7 @@ function PreventEdgeShortcutCreation
Enable Windows Subsystem for Linux (WSL), install the latest WSL Linux kernel version, and a Linux distribution using a pop-up form
.EXAMPLE
WSL
Install-WSL
.NOTES
The "Receive updates for other Microsoft products" setting will be enabled automatically to receive kernel updates
@ -8571,7 +8571,7 @@ function PreventEdgeShortcutCreation
.NOTES
Machine-wide
#>
function WSL
function Install-WSL
{
Add-Type -AssemblyName PresentationCore, PresentationFramework

2
src/Sophia_Script_for_Windows_10_LTSC_2021/Sophia.ps1

@ -911,7 +911,7 @@ PreventEdgeShortcutCreation -Channels Stable, Beta, Dev, Canary
Установить подсистему Windows для Linux (WSL), последний пакет обновления ядра Linux и дистрибутив Linux, используя всплывающую форму
Параметр "При обновлении Windows получать обновления для других продуктов Майкрософт" будет включен автоматически в Центре обновлении Windows, чтобы получать обновления ядра
#>
# WSL
# Install-WSL
#endregion WSL
#region Start menu

119
src/Sophia_Script_for_Windows_10_PowerShell_7/Module/Sophia.psm1

@ -4455,7 +4455,7 @@ function OneDrive
$UserEmail = Get-ItemProperty -Path HKCU:\Software\Microsoft\OneDrive\Accounts\Personal -Name UserEmail -ErrorAction Ignore
if ($PresetName -and $UserEmail)
{
# Exit if user accidentelly set function in preset to uninstall but he's logged into the app
# Exit if user accidentally set function in preset to uninstall but he's logged into the app
return
}
@ -9288,8 +9288,12 @@ function InstallVCRedist
if ([System.Version](Get-AppxPackage -Name Microsoft.DesktopAppInstaller -ErrorAction Ignore).Version -ge [System.Version]"1.17")
{
# https://github.com/microsoft/winget-pkgs/tree/master/manifests/m/Microsoft/VCRedist/2015%2B
winget install --id=Microsoft.VCRedist.2015+.x86 --exact --accept-source-agreements
winget install --id=Microsoft.VCRedist.2015+.x64 --exact --accept-source-agreements
# PowerShell 5.1 (7.3 too) interprets 8.3 file name literally, if an environment variable contains a non-latin word
Get-ChildItem -Path "$env:TEMP\WinGet" -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
}
else
{
@ -9319,8 +9323,7 @@ function InstallVCRedist
"$DownloadsFolder\VC_redist.x86.exe",
"$DownloadsFolder\VC_redist.x64.exe",
"$env:TEMP\dd_vcredist_x86_*.log",
"$env:TEMP\dd_vcredist_amd64_*.log",
"$env:TEMP\WinGet"
"$env:TEMP\dd_vcredist_amd64_*.log"
)
Get-ChildItem -Path $Paths -Recurse -Force | Remove-Item -Recurse -Force -ErrorAction Ignore
}
@ -9365,15 +9368,20 @@ function InstallDotNetRuntimes
if ([System.Version](Get-AppxPackage -Name Microsoft.DesktopAppInstaller -ErrorAction Ignore).Version -ge [System.Version]"1.17")
{
# https://github.com/microsoft/winget-pkgs/tree/master/manifests/m/Microsoft/DotNet/DesktopRuntime/6
# .NET Desktop Runtime 6 x86
winget install --id=Microsoft.DotNet.DesktopRuntime.6 --architecture x86 --exact --accept-source-agreements
# .NET Desktop Runtime 7 x64
# .NET Desktop Runtime 6 x64
winget install --id=Microsoft.DotNet.DesktopRuntime.6 --architecture x64 --exact --accept-source-agreements
# https://github.com/microsoft/winget-pkgs/tree/master/manifests/m/Microsoft/DotNet/DesktopRuntime/7
# .NET Desktop Runtime 7 x86
winget install --id=Microsoft.DotNet.DesktopRuntime.7 --architecture x86 --exact --accept-source-agreements
# .NET Desktop Runtime 7 x64
winget install --id=Microsoft.DotNet.DesktopRuntime.7 --architecture x64 --exact --accept-source-agreements
# PowerShell 5.1 (7.3 too) interprets 8.3 file name literally, if an environment variable contains a non-latin word
Get-ChildItem -Path "$env:TEMP\WinGet" -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
}
else
{
@ -9639,11 +9647,11 @@ function PreventEdgeShortcutCreation
.SYNOPSIS
Windows Subsystem for Linux (WSL)
.PARAMETER Install
.PARAMETER
Enable Windows Subsystem for Linux (WSL), install the latest WSL Linux kernel version, and a Linux distribution using a pop-up form
.EXAMPLE
WSL
Install-WSL
.NOTES
The "Receive updates for other Microsoft products" setting will be enabled automatically to receive kernel updates
@ -9651,8 +9659,17 @@ function PreventEdgeShortcutCreation
.NOTES
Machine-wide
#>
function WSL
function Install-WSL
{
[System.Console]::OutputEncoding = [System.Text.Encoding]::Unicode
$Distros = (wsl --list --online | Select-Object -Skip 8).Replace(" ", "").Replace("* ", "") | ForEach-Object -Process {
[PSCustomObject]@{
"Distro" = $_ -split " ", 2 | Select-Object -Last 1
"Alias" = $_ -split " ", 2 | Select-Object -First 1
}
}
Add-Type -AssemblyName PresentationCore, PresentationFramework
#region Variables
@ -9666,19 +9683,12 @@ function WSL
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Name="Window"
Title="WSL"
MinHeight="400" MinWidth="350"
MinHeight="460" MinWidth="350"
SizeToContent="WidthAndHeight" WindowStartupLocation="CenterScreen"
TextOptions.TextFormattingMode="Display" SnapsToDevicePixels="True"
FontFamily="Candara" FontSize="16" ShowInTaskbar="True"
Background="#F1F1F1" Foreground="#262626">
<Window.Resources>
<Style TargetType="StackPanel" x:Key="PanelContainerStyle">
<Setter Property="Grid.Row" Value="0"/>
<Setter Property="Orientation" Value="Vertical"/>
</Style>
<Style TargetType="StackPanel" x:Key="PanelElementStyle">
<Setter Property="Orientation" Value="Horizontal"/>
</Style>
<Style TargetType="RadioButton">
<Setter Property="VerticalAlignment" Value="Center"/>
<Setter Property="Margin" Value="10"/>
@ -9698,47 +9708,7 @@ function WSL
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<StackPanel Name="PanelContainer" Style="{StaticResource PanelContainerStyle}">
<StackPanel Style="{StaticResource PanelElementStyle}">
<RadioButton Name="RadioButtonUbuntu" GroupName="NixNames" Tag="Ubuntu"/>
<TextBlock Text="Ubuntu"/>
</StackPanel>
<StackPanel Style="{StaticResource PanelElementStyle}">
<RadioButton Name="RadioButtonDebian" GroupName="NixNames" Tag="Debian"/>
<TextBlock Text="Debian GNU/Linux"/>
</StackPanel>
<StackPanel Style="{StaticResource PanelElementStyle}">
<RadioButton Name="RadioButtonKali" GroupName="NixNames" Tag="kali-linux"/>
<TextBlock Text="Kali Linux Rolling"/>
</StackPanel>
<StackPanel Style="{StaticResource PanelElementStyle}">
<RadioButton Name="RadioButtonOpenSuse" GroupName="NixNames" Tag="openSUSE-42"/>
<TextBlock Text="openSUSE Leap 42"/>
</StackPanel>
<StackPanel Style="{StaticResource PanelElementStyle}">
<RadioButton Name="RadioButtonSuse" GroupName="NixNames" Tag="SLES-12"/>
<TextBlock Text="SUSE Linux Enterprise Server v12"/>
</StackPanel>
<StackPanel Style="{StaticResource PanelElementStyle}">
<RadioButton Name="RadioButtonUbuntu16" GroupName="NixNames" Tag="Ubuntu-16.04"/>
<TextBlock Text="Ubuntu 16.04 LTS"/>
</StackPanel>
<StackPanel Style="{StaticResource PanelElementStyle}">
<RadioButton Name="RadioButtonUbuntu18" GroupName="NixNames" Tag="Ubuntu-18.04"/>
<TextBlock Text="Ubuntu 18.04 LTS"/>
</StackPanel>
<StackPanel Style="{StaticResource PanelElementStyle}">
<RadioButton Name="RadioButtonUbuntu20" GroupName="NixNames" Tag="Ubuntu-20.04"/>
<TextBlock Text="Ubuntu 20.04 LTS"/>
</StackPanel>
</StackPanel>
<StackPanel Name="PanelContainer" Grid.Row="0"/>
<Button Name="ButtonInstall" Content="Install" Grid.Row="2"/>
</Grid>
</Window>
@ -9757,7 +9727,11 @@ function WSL
function ButtonInstallClicked
{
Write-Warning -Message $Script:CommandTag
Start-Process -FilePath wsl.exe -ArgumentList "--install --distribution $Script:CommandTag" -Wait
$Form.Close()
}
#endregion
@ -9765,11 +9739,23 @@ function WSL
$XAML.SelectNodes("//*[@*[contains(translate(name(.),'n','N'),'Name')]]") | ForEach-Object -Process {
$control = $Form.FindName($_.Name)
Set-Variable -Name ($_.Name) -Value $control
if ($Control.Template.TargetType.Name -eq "RadioButton")
{
$Control.add_Checked({RadioButtonChecked})
}
}
foreach ($Distro in $Distros)
{
$Panel = New-Object -TypeName System.Windows.Controls.StackPanel
$RadioButton = New-Object -TypeName System.Windows.Controls.RadioButton
$TextBlock = New-Object -TypeName System.Windows.Controls.TextBlock
$Panel.Orientation = "Horizontal"
$RadioButton.GroupName = "WslDistro"
$RadioButton.Tag = $Distro.Alias
$RadioButton.add_Checked({RadioButtonChecked})
$TextBlock.Text = $Distro.Distro
$Panel.Children.Add($RadioButton) | Out-Null
$Panel.Children.Add($TextBlock) | Out-Null
$PanelContainer.Children.Add($Panel) | Out-Null
}
$ButtonInstall.add_Click({ButtonInstallClicked})
#region Sendkey function
@ -9797,7 +9783,7 @@ public static extern bool SetForegroundWindow(IntPtr hWnd);
Add-Type @SetForegroundWindow
}
Get-Process | Where-Object -FilterScript {(($_.ProcessName -eq "powershell") -or ($_.ProcessName -eq "WindowsTerminal")) -and ($_.MainWindowTitle -match "Sophia Script for Windows 10")} | ForEach-Object -Process {
Get-Process | Where-Object -FilterScript {(($_.ProcessName -eq "powershell") -or ($_.ProcessName -eq "WindowsTerminal")) -and ($_.MainWindowTitle -match "Sophia Script for Windows 11")} | ForEach-Object -Process {
# Show window, if minimized
[WinAPI.ForegroundWindow]::ShowWindowAsync($_.MainWindowHandle, 10)
@ -9819,6 +9805,9 @@ public static extern bool SetForegroundWindow(IntPtr hWnd);
# Receive updates for other Microsoft products when you update Windows
(New-Object -ComObject Microsoft.Update.ServiceManager).AddService2("7971f918-a847-4430-9279-4a52d1efe18d", 7, "")
# Trigger Windows Update for detecting new updates
(New-Object -ComObject Microsoft.Update.AutoUpdate).DetectNow()
}
#endregion WSL
@ -10396,7 +10385,7 @@ function UninstallUWPApps
# HEVC Video Extensions from Device Manufacturer
"Microsoft.HEVCVideoExtension",
# HEIF Image Extensions
# HEVC Image Extensions
"Microsoft.HEIFImageExtension",
# MPEG-2 Video Extension
@ -11082,10 +11071,10 @@ public static extern bool SetForegroundWindow(IntPtr hWnd);
Open Microsoft Store "HEVC Video Extensions from Device Manufacturer" page to install the extension manually
.EXAMPLE
HEIF -Install
HEVC -Install
.EXAMPLE
HEIF -Manually
HEVC -Manually
.LINK
https://www.microsoft.com/store/productId/9n4wgh0z6vhq
@ -11099,7 +11088,7 @@ public static extern bool SetForegroundWindow(IntPtr hWnd);
.NOTES
Current user
#>
function HEIF
function HEVC
{
param
(

8
src/Sophia_Script_for_Windows_10_PowerShell_7/Sophia.ps1

@ -27,7 +27,7 @@
.NOTES
Supported Windows 10 versions
Versions: 21H2/22H2
Builds: 1904x.2364+
Builds: 19044.2364+
Editions: Home/Pro/Enterprise
Architecture: x64
@ -1021,7 +1021,7 @@ PreventEdgeShortcutCreation -Channels Stable, Beta, Dev, Canary
Установить подсистему Windows для Linux (WSL), последний пакет обновления ядра Linux и дистрибутив Linux, используя всплывающую форму
Параметр "При обновлении Windows получать обновления для других продуктов Майкрософт" будет включен автоматически в Центре обновлении Windows, чтобы получать обновления ядра
#>
# WSL
# Install-WSL
#endregion WSL
#region Start menu
@ -1090,7 +1090,7 @@ UninstallUWPApps
# Download and install "HEVC Video Extensions from Device Manufacturer" to be able to open .heic and .heif formats
# Скачать и установить "Расширения для видео HEVC от производителя устройства", чтобы иметь возможность открывать форматы .heic и .heif
HEIF -Install
HEVC -Install
<#
Open Microsoft Store "HEVC Video Extensions from Device Manufacturer" page to install this extension manually to be able to open .heic and .heif formats
@ -1099,7 +1099,7 @@ HEIF -Install
Открыть страницу "Расширения для видео HEVC от производителя устройства" в Microsoft Store, чтобы вручную установить расширение для открытия форматов .heic и .heif
Расширение может быть установлено бесплатно без учетной записи Microsoft
#>
# HEIF -Manually
# HEVC -Manually
# Disable Cortana autostarting
# Выключить автозагрузку Кортана

124
src/Sophia_Script_for_Windows_11/Module/Sophia.psm1

@ -3922,16 +3922,10 @@ function OneDrive
return
}
# Check if script was launched from OneDrive folder and preset file has function to uninstall OneDrive
# Check how the script was invoked: via a preset or Function.ps1
$PresetName = (Get-PSCallStack).Position | Where-Object -FilterScript {
(($_.File -match ".ps1") -and ($_.File -notmatch "Functions.ps1")) -and ($_.Text -eq "OneDrive -Uninstall") -or ($_.Text -match "Invoke-Expression")
}
# Check if user is logged into OneDrive account (Microsoft account)
$UserEmail = Get-ItemProperty -Path HKCU:\Software\Microsoft\OneDrive\Accounts\Personal -Name UserEmail -ErrorAction Ignore
if ($PresetName -and $UserEmail)
if ($UserEmail)
{
# Exit if user accidentelly set function in preset to uninstall but he's logged into the app
return
}
@ -8790,8 +8784,12 @@ function InstallVCRedist
if ([System.Version](Get-AppxPackage -Name Microsoft.DesktopAppInstaller -ErrorAction Ignore).Version -ge [System.Version]"1.17")
{
# https://github.com/microsoft/winget-pkgs/tree/master/manifests/m/Microsoft/VCRedist/2015%2B
winget install --id=Microsoft.VCRedist.2015+.x86 --exact --accept-source-agreements
winget install --id=Microsoft.VCRedist.2015+.x64 --exact --accept-source-agreements
# PowerShell 5.1 (7.3 too) interprets 8.3 file name literally, if an environment variable contains a non-latin word
Get-ChildItem -Path "$env:TEMP\WinGet" -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
}
else
{
@ -8821,8 +8819,7 @@ function InstallVCRedist
"$DownloadsFolder\VC_redist.x86.exe",
"$DownloadsFolder\VC_redist.x64.exe",
"$env:TEMP\dd_vcredist_x86_*.log",
"$env:TEMP\dd_vcredist_amd64_*.log",
"$env:TEMP\WinGet"
"$env:TEMP\dd_vcredist_amd64_*.log"
)
Get-ChildItem -Path $Paths -Recurse -Force | Remove-Item -Recurse -Force -ErrorAction Ignore
}
@ -8867,15 +8864,20 @@ function InstallDotNetRuntimes
if ([System.Version](Get-AppxPackage -Name Microsoft.DesktopAppInstaller -ErrorAction Ignore).Version -ge [System.Version]"1.17")
{
# https://github.com/microsoft/winget-pkgs/tree/master/manifests/m/Microsoft/DotNet/DesktopRuntime/6
# .NET Desktop Runtime 6 x86
winget install --id=Microsoft.DotNet.DesktopRuntime.6 --architecture x86 --exact --accept-source-agreements
# .NET Desktop Runtime 6 x64
winget install --id=Microsoft.DotNet.DesktopRuntime.6 --architecture x64 --exact --accept-source-agreements
# https://github.com/microsoft/winget-pkgs/tree/master/manifests/m/Microsoft/DotNet/DesktopRuntime/7
# .NET Desktop Runtime 7 x86
winget install --id=Microsoft.DotNet.DesktopRuntime.7 --architecture x86 --exact --accept-source-agreements
# .NET Desktop Runtime 7 x64
winget install --id=Microsoft.DotNet.DesktopRuntime.7 --architecture x64 --exact --accept-source-agreements
# PowerShell 5.1 (7.3 too) interprets 8.3 file name literally, if an environment variable contains a non-latin word
Get-ChildItem -Path "$env:TEMP\WinGet" -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
}
else
{
@ -8953,8 +8955,7 @@ function InstallDotNetRuntimes
$Paths = @(
"$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x86.exe",
"$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x64.exe",
"$env:TEMP\Microsoft_.NET_Runtime*.log",
"$env:TEMP\WinGet"
"$env:TEMP\Microsoft_.NET_Runtime*.log"
)
Get-ChildItem -Path $Paths -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
}
@ -9265,11 +9266,11 @@ function PreventEdgeShortcutCreation
.SYNOPSIS
Windows Subsystem for Linux (WSL)
.PARAMETER Install
.PARAMETER
Enable Windows Subsystem for Linux (WSL), install the latest WSL Linux kernel version, and a Linux distribution using a pop-up form
.EXAMPLE
WSL
Install-WSL
.NOTES
The "Receive updates for other Microsoft products" setting will be enabled automatically to receive kernel updates
@ -9277,8 +9278,17 @@ function PreventEdgeShortcutCreation
.NOTES
Machine-wide
#>
function WSL
function Install-WSL
{
[System.Console]::OutputEncoding = [System.Text.Encoding]::Unicode
$Distros = (wsl --list --online | Select-Object -Skip 8).Replace(" ", "").Replace("* ", "") | ForEach-Object -Process {
[PSCustomObject]@{
"Distro" = $_ -split " ", 2 | Select-Object -Last 1
"Alias" = $_ -split " ", 2 | Select-Object -First 1
}
}
Add-Type -AssemblyName PresentationCore, PresentationFramework
#region Variables
@ -9292,19 +9302,12 @@ function WSL
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Name="Window"
Title="WSL"
MinHeight="400" MinWidth="350"
MinHeight="460" MinWidth="350"
SizeToContent="WidthAndHeight" WindowStartupLocation="CenterScreen"
TextOptions.TextFormattingMode="Display" SnapsToDevicePixels="True"
FontFamily="Candara" FontSize="16" ShowInTaskbar="True"
Background="#F1F1F1" Foreground="#262626">
<Window.Resources>
<Style TargetType="StackPanel" x:Key="PanelContainerStyle">
<Setter Property="Grid.Row" Value="0"/>
<Setter Property="Orientation" Value="Vertical"/>
</Style>
<Style TargetType="StackPanel" x:Key="PanelElementStyle">
<Setter Property="Orientation" Value="Horizontal"/>
</Style>
<Style TargetType="RadioButton">
<Setter Property="VerticalAlignment" Value="Center"/>
<Setter Property="Margin" Value="10"/>
@ -9324,47 +9327,7 @@ function WSL
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<StackPanel Name="PanelContainer" Style="{StaticResource PanelContainerStyle}">
<StackPanel Style="{StaticResource PanelElementStyle}">
<RadioButton Name="RadioButtonUbuntu" GroupName="NixNames" Tag="Ubuntu"/>
<TextBlock Text="Ubuntu"/>
</StackPanel>
<StackPanel Style="{StaticResource PanelElementStyle}">
<RadioButton Name="RadioButtonDebian" GroupName="NixNames" Tag="Debian"/>
<TextBlock Text="Debian GNU/Linux"/>
</StackPanel>
<StackPanel Style="{StaticResource PanelElementStyle}">
<RadioButton Name="RadioButtonKali" GroupName="NixNames" Tag="kali-linux"/>
<TextBlock Text="Kali Linux Rolling"/>
</StackPanel>
<StackPanel Style="{StaticResource PanelElementStyle}">
<RadioButton Name="RadioButtonOpenSuse" GroupName="NixNames" Tag="openSUSE-42"/>
<TextBlock Text="openSUSE Leap 42"/>
</StackPanel>
<StackPanel Style="{StaticResource PanelElementStyle}">
<RadioButton Name="RadioButtonSuse" GroupName="NixNames" Tag="SLES-12"/>
<TextBlock Text="SUSE Linux Enterprise Server v12"/>
</StackPanel>
<StackPanel Style="{StaticResource PanelElementStyle}">
<RadioButton Name="RadioButtonUbuntu16" GroupName="NixNames" Tag="Ubuntu-16.04"/>
<TextBlock Text="Ubuntu 16.04 LTS"/>
</StackPanel>
<StackPanel Style="{StaticResource PanelElementStyle}">
<RadioButton Name="RadioButtonUbuntu18" GroupName="NixNames" Tag="Ubuntu-18.04"/>
<TextBlock Text="Ubuntu 18.04 LTS"/>
</StackPanel>
<StackPanel Style="{StaticResource PanelElementStyle}">
<RadioButton Name="RadioButtonUbuntu20" GroupName="NixNames" Tag="Ubuntu-20.04"/>
<TextBlock Text="Ubuntu 20.04 LTS"/>
</StackPanel>
</StackPanel>
<StackPanel Name="PanelContainer" Grid.Row="0"/>
<Button Name="ButtonInstall" Content="Install" Grid.Row="2"/>
</Grid>
</Window>
@ -9383,7 +9346,11 @@ function WSL
function ButtonInstallClicked
{
Write-Warning -Message $Script:CommandTag
Start-Process -FilePath wsl.exe -ArgumentList "--install --distribution $Script:CommandTag" -Wait
$Form.Close()
}
#endregion
@ -9391,11 +9358,23 @@ function WSL
$XAML.SelectNodes("//*[@*[contains(translate(name(.),'n','N'),'Name')]]") | ForEach-Object -Process {
$control = $Form.FindName($_.Name)
Set-Variable -Name ($_.Name) -Value $control
if ($Control.Template.TargetType.Name -eq "RadioButton")
{
$Control.add_Checked({RadioButtonChecked})
}
}
foreach ($Distro in $Distros)
{
$Panel = New-Object -TypeName System.Windows.Controls.StackPanel
$RadioButton = New-Object -TypeName System.Windows.Controls.RadioButton
$TextBlock = New-Object -TypeName System.Windows.Controls.TextBlock
$Panel.Orientation = "Horizontal"
$RadioButton.GroupName = "WslDistro"
$RadioButton.Tag = $Distro.Alias
$RadioButton.add_Checked({RadioButtonChecked})
$TextBlock.Text = $Distro.Distro
$Panel.Children.Add($RadioButton) | Out-Null
$Panel.Children.Add($TextBlock) | Out-Null
$PanelContainer.Children.Add($Panel) | Out-Null
}
$ButtonInstall.add_Click({ButtonInstallClicked})
#region Sendkey function
@ -9445,6 +9424,9 @@ public static extern bool SetForegroundWindow(IntPtr hWnd);
# Receive updates for other Microsoft products when you update Windows
(New-Object -ComObject Microsoft.Update.ServiceManager).AddService2("7971f918-a847-4430-9279-4a52d1efe18d", 7, "")
# Trigger Windows Update for detecting new updates
(New-Object -ComObject Microsoft.Update.AutoUpdate).DetectNow()
}
#endregion WSL
@ -9767,7 +9749,7 @@ function UninstallUWPApps
# Raw Image Extension
"Microsoft.RawImageExtension",
# HEIF Image Extensions
# HEVC Image Extensions
"Microsoft.HEIFImageExtension",
# MPEG-2 Video Extension
@ -10473,10 +10455,10 @@ public static extern bool SetForegroundWindow(IntPtr hWnd);
Open Microsoft Store "HEVC Video Extensions from Device Manufacturer" page to install the extension manually
.EXAMPLE
HEIF -Install
HEVC -Install
.EXAMPLE
HEIF -Manually
HEVC -Manually
.LINK
https://www.microsoft.com/store/productId/9n4wgh0z6vhq
@ -10490,7 +10472,7 @@ public static extern bool SetForegroundWindow(IntPtr hWnd);
.NOTES
Current user
#>
function HEIF
function HEVC
{
param
(

6
src/Sophia_Script_for_Windows_11/Sophia.ps1

@ -956,7 +956,7 @@ PreventEdgeShortcutCreation -Channels Stable, Beta, Dev, Canary
Установить подсистему Windows для Linux (WSL), последний пакет обновления ядра Linux и дистрибутив Linux, используя всплывающую форму
Параметр "При обновлении Windows получать обновления для других продуктов Майкрософт" будет включен автоматически в Центре обновлении Windows, чтобы получать обновления ядра
#>
# WSL
# Install-WSL
#endregion WSL
#region Start menu
@ -1013,7 +1013,7 @@ UninstallUWPApps
Скачать и установить "Расширения для видео HEVC от производителя устройства", чтобы иметь возможность открывать форматы .heic и .heif
Расширение уже установлено в Windows 11 22H2 по умолчанию
#>
HEIF -Install
HEVC -Install
<#
Open Microsoft Store "HEVC Video Extensions from Device Manufacturer" page to install this extension manually to be able to open .heic and .heif formats
@ -1022,7 +1022,7 @@ HEIF -Install
Открыть страницу "Расширения для видео HEVC от производителя устройства" в Microsoft Store, чтобы вручную установить расширение для открытия форматов .heic и .heif
Расширение может быть установлено бесплатно без учетной записи Microsoft
#>
# HEIF -Manually
# HEVC -Manually
# Disable Cortana autostarting
# Выключить автозагрузку Кортана

118
src/Sophia_Script_for_Windows_11_PowerShell_7/Module/Sophia.psm1

@ -3935,7 +3935,7 @@ function OneDrive
$UserEmail = Get-ItemProperty -Path HKCU:\Software\Microsoft\OneDrive\Accounts\Personal -Name UserEmail -ErrorAction Ignore
if ($PresetName -and $UserEmail)
{
# Exit if user accidentelly set function in preset to uninstall but he's logged into the app
# Exit if user accidentally set function in preset to uninstall but he's logged into the app
return
}
@ -8798,8 +8798,12 @@ function InstallVCRedist
if ([System.Version](Get-AppxPackage -Name Microsoft.DesktopAppInstaller -ErrorAction Ignore).Version -ge [System.Version]"1.17")
{
# https://github.com/microsoft/winget-pkgs/tree/master/manifests/m/Microsoft/VCRedist/2015%2B
winget install --id=Microsoft.VCRedist.2015+.x86 --exact --accept-source-agreements
winget install --id=Microsoft.VCRedist.2015+.x64 --exact --accept-source-agreements
# PowerShell 5.1 (7.3 too) interprets 8.3 file name literally, if an environment variable contains a non-latin word
Get-ChildItem -Path "$env:TEMP\WinGet" -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
}
else
{
@ -8829,8 +8833,7 @@ function InstallVCRedist
"$DownloadsFolder\VC_redist.x86.exe",
"$DownloadsFolder\VC_redist.x64.exe",
"$env:TEMP\dd_vcredist_x86_*.log",
"$env:TEMP\dd_vcredist_amd64_*.log",
"$env:TEMP\WinGet"
"$env:TEMP\dd_vcredist_amd64_*.log"
)
Get-ChildItem -Path $Paths -Recurse -Force | Remove-Item -Recurse -Force -ErrorAction Ignore
}
@ -8875,15 +8878,20 @@ function InstallDotNetRuntimes
if ([System.Version](Get-AppxPackage -Name Microsoft.DesktopAppInstaller -ErrorAction Ignore).Version -ge [System.Version]"1.17")
{
# https://github.com/microsoft/winget-pkgs/tree/master/manifests/m/Microsoft/DotNet/DesktopRuntime/6
# .NET Desktop Runtime 6 x86
winget install --id=Microsoft.DotNet.DesktopRuntime.6 --architecture x86 --exact --accept-source-agreements
# .NET Desktop Runtime 6 x64
winget install --id=Microsoft.DotNet.DesktopRuntime.6 --architecture x64 --exact --accept-source-agreements
# https://github.com/microsoft/winget-pkgs/tree/master/manifests/m/Microsoft/DotNet/DesktopRuntime/7
# .NET Desktop Runtime 7 x86
winget install --id=Microsoft.DotNet.DesktopRuntime.7 --architecture x86 --exact --accept-source-agreements
# .NET Desktop Runtime 7 x64
winget install --id=Microsoft.DotNet.DesktopRuntime.7 --architecture x64 --exact --accept-source-agreements
# PowerShell 5.1 (7.3 too) interprets 8.3 file name literally, if an environment variable contains a non-latin word
Get-ChildItem -Path "$env:TEMP\WinGet" -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
}
else
{
@ -8961,8 +8969,7 @@ function InstallDotNetRuntimes
$Paths = @(
"$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x86.exe",
"$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x64.exe",
"$env:TEMP\Microsoft_.NET_Runtime*.log",
"$env:TEMP\WinGet"
"$env:TEMP\Microsoft_.NET_Runtime*.log"
)
Get-ChildItem -Path $Paths -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
}
@ -9273,11 +9280,11 @@ function PreventEdgeShortcutCreation
.SYNOPSIS
Windows Subsystem for Linux (WSL)
.PARAMETER Install
.PARAMETER
Enable Windows Subsystem for Linux (WSL), install the latest WSL Linux kernel version, and a Linux distribution using a pop-up form
.EXAMPLE
WSL
Install-WSL
.NOTES
The "Receive updates for other Microsoft products" setting will be enabled automatically to receive kernel updates
@ -9285,8 +9292,17 @@ function PreventEdgeShortcutCreation
.NOTES
Machine-wide
#>
function WSL
function Install-WSL
{
[System.Console]::OutputEncoding = [System.Text.Encoding]::Unicode
$Distros = (wsl --list --online | Select-Object -Skip 8).Replace(" ", "").Replace("* ", "") | ForEach-Object -Process {
[PSCustomObject]@{
"Distro" = $_ -split " ", 2 | Select-Object -Last 1
"Alias" = $_ -split " ", 2 | Select-Object -First 1
}
}
Add-Type -AssemblyName PresentationCore, PresentationFramework
#region Variables
@ -9300,19 +9316,12 @@ function WSL
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Name="Window"
Title="WSL"
MinHeight="400" MinWidth="350"
MinHeight="460" MinWidth="350"
SizeToContent="WidthAndHeight" WindowStartupLocation="CenterScreen"
TextOptions.TextFormattingMode="Display" SnapsToDevicePixels="True"
FontFamily="Candara" FontSize="16" ShowInTaskbar="True"
Background="#F1F1F1" Foreground="#262626">
<Window.Resources>
<Style TargetType="StackPanel" x:Key="PanelContainerStyle">
<Setter Property="Grid.Row" Value="0"/>
<Setter Property="Orientation" Value="Vertical"/>
</Style>
<Style TargetType="StackPanel" x:Key="PanelElementStyle">
<Setter Property="Orientation" Value="Horizontal"/>
</Style>
<Style TargetType="RadioButton">
<Setter Property="VerticalAlignment" Value="Center"/>
<Setter Property="Margin" Value="10"/>
@ -9332,47 +9341,7 @@ function WSL
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<StackPanel Name="PanelContainer" Style="{StaticResource PanelContainerStyle}">
<StackPanel Style="{StaticResource PanelElementStyle}">
<RadioButton Name="RadioButtonUbuntu" GroupName="NixNames" Tag="Ubuntu"/>
<TextBlock Text="Ubuntu"/>
</StackPanel>
<StackPanel Style="{StaticResource PanelElementStyle}">
<RadioButton Name="RadioButtonDebian" GroupName="NixNames" Tag="Debian"/>
<TextBlock Text="Debian GNU/Linux"/>
</StackPanel>
<StackPanel Style="{StaticResource PanelElementStyle}">
<RadioButton Name="RadioButtonKali" GroupName="NixNames" Tag="kali-linux"/>
<TextBlock Text="Kali Linux Rolling"/>
</StackPanel>
<StackPanel Style="{StaticResource PanelElementStyle}">
<RadioButton Name="RadioButtonOpenSuse" GroupName="NixNames" Tag="openSUSE-42"/>
<TextBlock Text="openSUSE Leap 42"/>
</StackPanel>
<StackPanel Style="{StaticResource PanelElementStyle}">
<RadioButton Name="RadioButtonSuse" GroupName="NixNames" Tag="SLES-12"/>
<TextBlock Text="SUSE Linux Enterprise Server v12"/>
</StackPanel>
<StackPanel Style="{StaticResource PanelElementStyle}">
<RadioButton Name="RadioButtonUbuntu16" GroupName="NixNames" Tag="Ubuntu-16.04"/>
<TextBlock Text="Ubuntu 16.04 LTS"/>
</StackPanel>
<StackPanel Style="{StaticResource PanelElementStyle}">
<RadioButton Name="RadioButtonUbuntu18" GroupName="NixNames" Tag="Ubuntu-18.04"/>
<TextBlock Text="Ubuntu 18.04 LTS"/>
</StackPanel>
<StackPanel Style="{StaticResource PanelElementStyle}">
<RadioButton Name="RadioButtonUbuntu20" GroupName="NixNames" Tag="Ubuntu-20.04"/>
<TextBlock Text="Ubuntu 20.04 LTS"/>
</StackPanel>
</StackPanel>
<StackPanel Name="PanelContainer" Grid.Row="0"/>
<Button Name="ButtonInstall" Content="Install" Grid.Row="2"/>
</Grid>
</Window>
@ -9391,7 +9360,11 @@ function WSL
function ButtonInstallClicked
{
Write-Warning -Message $Script:CommandTag
Start-Process -FilePath wsl.exe -ArgumentList "--install --distribution $Script:CommandTag" -Wait
$Form.Close()
}
#endregion
@ -9399,11 +9372,23 @@ function WSL
$XAML.SelectNodes("//*[@*[contains(translate(name(.),'n','N'),'Name')]]") | ForEach-Object -Process {
$control = $Form.FindName($_.Name)
Set-Variable -Name ($_.Name) -Value $control
if ($Control.Template.TargetType.Name -eq "RadioButton")
{
$Control.add_Checked({RadioButtonChecked})
}
}
foreach ($Distro in $Distros)
{
$Panel = New-Object -TypeName System.Windows.Controls.StackPanel
$RadioButton = New-Object -TypeName System.Windows.Controls.RadioButton
$TextBlock = New-Object -TypeName System.Windows.Controls.TextBlock
$Panel.Orientation = "Horizontal"
$RadioButton.GroupName = "WslDistro"
$RadioButton.Tag = $Distro.Alias
$RadioButton.add_Checked({RadioButtonChecked})
$TextBlock.Text = $Distro.Distro
$Panel.Children.Add($RadioButton) | Out-Null
$Panel.Children.Add($TextBlock) | Out-Null
$PanelContainer.Children.Add($Panel) | Out-Null
}
$ButtonInstall.add_Click({ButtonInstallClicked})
#region Sendkey function
@ -9453,6 +9438,9 @@ public static extern bool SetForegroundWindow(IntPtr hWnd);
# Receive updates for other Microsoft products when you update Windows
(New-Object -ComObject Microsoft.Update.ServiceManager).AddService2("7971f918-a847-4430-9279-4a52d1efe18d", 7, "")
# Trigger Windows Update for detecting new updates
(New-Object -ComObject Microsoft.Update.AutoUpdate).DetectNow()
}
#endregion WSL
@ -9785,7 +9773,7 @@ function UninstallUWPApps
# Raw Image Extension
"Microsoft.RawImageExtension",
# HEIF Image Extensions
# HEVC Image Extensions
"Microsoft.HEIFImageExtension",
# MPEG-2 Video Extension
@ -10501,10 +10489,10 @@ public static extern bool SetForegroundWindow(IntPtr hWnd);
Open Microsoft Store "HEVC Video Extensions from Device Manufacturer" page to install the extension manually
.EXAMPLE
HEIF -Install
HEVC -Install
.EXAMPLE
HEIF -Manually
HEVC -Manually
.LINK
https://www.microsoft.com/store/productId/9n4wgh0z6vhq
@ -10518,7 +10506,7 @@ public static extern bool SetForegroundWindow(IntPtr hWnd);
.NOTES
Current user
#>
function HEIF
function HEVC
{
param
(

6
src/Sophia_Script_for_Windows_11_PowerShell_7/Sophia.ps1

@ -965,7 +965,7 @@ PreventEdgeShortcutCreation -Channels Stable, Beta, Dev, Canary
Установить подсистему Windows для Linux (WSL), последний пакет обновления ядра Linux и дистрибутив Linux, используя всплывающую форму
Параметр "При обновлении Windows получать обновления для других продуктов Майкрософт" будет включен автоматически в Центре обновлении Windows, чтобы получать обновления ядра
#>
# WSL
# Install-WSL
#endregion WSL
#region Start menu
@ -1022,7 +1022,7 @@ UninstallUWPApps
Скачать и установить "Расширения для видео HEVC от производителя устройства", чтобы иметь возможность открывать форматы .heic и .heif
Расширение уже установлено в Windows 11 22H2 по умолчанию
#>
HEIF -Install
HEVC -Install
<#
Open Microsoft Store "HEVC Video Extensions from Device Manufacturer" page to install this extension manually to be able to open .heic and .heif formats
@ -1031,7 +1031,7 @@ HEIF -Install
Открыть страницу "Расширения для видео HEVC от производителя устройства" в Microsoft Store, чтобы вручную установить расширение для открытия форматов .heic и .heif
Расширение может быть установлено бесплатно без учетной записи Microsoft
#>
# HEIF -Manually
# HEVC -Manually
# Disable Cortana autostarting
# Выключить автозагрузку Кортана

Loading…
Cancel
Save