Browse Source

Improved HEVC package downloading function

master
Dmitry Nefedov 12 months ago
parent
commit
eb6adf1b9c
  1. 16
      src/Sophia_Script_for_Windows_10/Module/Sophia.psm1
  2. 2
      src/Sophia_Script_for_Windows_10_LTSC_2021/Module/Sophia.psm1
  3. 16
      src/Sophia_Script_for_Windows_10_PowerShell_7/Module/Sophia.psm1

16
src/Sophia_Script_for_Windows_10/Module/Sophia.psm1

@ -10836,7 +10836,7 @@ public static extern bool SetForegroundWindow(IntPtr hWnd);
Add-Type @Signature Add-Type @Signature
} }
Get-Process | Where-Object -FilterScript {(($_.ProcessName -eq "powershell") -or ($_.ProcessName -eq "WindowsTerminal")) -and ($_.MainWindowTitle -match "Sophia Script for Windows 11")} | ForEach-Object -Process { Get-Process | Where-Object -FilterScript {(($_.ProcessName -eq "powershell") -or ($_.ProcessName -eq "WindowsTerminal")) -and ($_.MainWindowTitle -match "Sophia Script for Windows 10")} | ForEach-Object -Process {
# Show window, if minimized # Show window, if minimized
[WinAPI.ForegroundWindow]::ShowWindowAsync($_.MainWindowHandle, 10) [WinAPI.ForegroundWindow]::ShowWindowAsync($_.MainWindowHandle, 10)
@ -12044,9 +12044,6 @@ public static extern bool SetForegroundWindow(IntPtr hWnd);
.NOTES .NOTES
The extension can be installed without Microsoft account The extension can be installed without Microsoft account
.NOTES
HEVC Video Extension is already installed in Windows 11 22H2 by default
.NOTES .NOTES
Current user Current user
#> #>
@ -12133,10 +12130,9 @@ function HEVC
} }
$Raw = Invoke-WebRequest @Parameters $Raw = Invoke-WebRequest @Parameters
# Parsing the page # Get a temp URL
$Raw | Select-String -Pattern '<tr style.*<a href=\"(?<url>.*)"\s.*>(?<text>.*)<\/a>' -AllMatches | ForEach-Object -Process {$_.Matches} | Where-Object -FilterScript {$_.Value -like "*HEVCVideoExtension*.appxbundle*"} | ForEach-Object -Process { $TempURL = $Raw.Links.href | Sort-Object -Property Length -Descending | Select-Object -First 1
$TempURL = ($_.Groups | Select-Object -Index 1).Value $HEVCPackageName = ($Raw.Links.outerHTML | Where-Object -FilterScript {$_ -match "appxbundle"}).Split("_") | Select-Object -Index 1
$HEVCPackageName = ($_.Groups | Select-Object -Index 2).Value.Split("_") | Select-Object -Index 1
# Installing "HEVC Video Extensions from Device Manufacturer" # Installing "HEVC Video Extensions from Device Manufacturer"
if ([System.Version]$HEVCPackageName -gt [System.Version](Get-AppxPackage -Name Microsoft.HEVCVideoExtension).Version) if ([System.Version]$HEVCPackageName -gt [System.Version](Get-AppxPackage -Name Microsoft.HEVCVideoExtension).Version)
@ -12159,6 +12155,10 @@ function HEVC
Add-AppxPackage -Path "$DownloadsFolder\Microsoft.HEVCVideoExtension_8wekyb3d8bbwe.appx" -Verbose Add-AppxPackage -Path "$DownloadsFolder\Microsoft.HEVCVideoExtension_8wekyb3d8bbwe.appx" -Verbose
Remove-Item -Path "$DownloadsFolder\Microsoft.HEVCVideoExtension_8wekyb3d8bbwe.appx" -Force Remove-Item -Path "$DownloadsFolder\Microsoft.HEVCVideoExtension_8wekyb3d8bbwe.appx" -Force
} }
else
{
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
} }
} }
catch [System.Net.WebException] catch [System.Net.WebException]

2
src/Sophia_Script_for_Windows_10_LTSC_2021/Module/Sophia.psm1

@ -9696,7 +9696,7 @@ public static extern bool SetForegroundWindow(IntPtr hWnd);
Add-Type @Signature Add-Type @Signature
} }
Get-Process | Where-Object -FilterScript {(($_.ProcessName -eq "powershell") -or ($_.ProcessName -eq "WindowsTerminal")) -and ($_.MainWindowTitle -match "Sophia Script for Windows 11")} | ForEach-Object -Process { Get-Process | Where-Object -FilterScript {(($_.ProcessName -eq "powershell") -or ($_.ProcessName -eq "WindowsTerminal")) -and ($_.MainWindowTitle -match "Sophia Script for Windows 10")} | ForEach-Object -Process {
# Show window, if minimized # Show window, if minimized
[WinAPI.ForegroundWindow]::ShowWindowAsync($_.MainWindowHandle, 10) [WinAPI.ForegroundWindow]::ShowWindowAsync($_.MainWindowHandle, 10)

16
src/Sophia_Script_for_Windows_10_PowerShell_7/Module/Sophia.psm1

@ -10840,7 +10840,7 @@ public static extern bool SetForegroundWindow(IntPtr hWnd);
Add-Type @Signature Add-Type @Signature
} }
Get-Process | Where-Object -FilterScript {(($_.ProcessName -eq "powershell") -or ($_.ProcessName -eq "WindowsTerminal")) -and ($_.MainWindowTitle -match "Sophia Script for Windows 11")} | ForEach-Object -Process { Get-Process | Where-Object -FilterScript {(($_.ProcessName -eq "powershell") -or ($_.ProcessName -eq "WindowsTerminal")) -and ($_.MainWindowTitle -match "Sophia Script for Windows 10")} | ForEach-Object -Process {
# Show window, if minimized # Show window, if minimized
[WinAPI.ForegroundWindow]::ShowWindowAsync($_.MainWindowHandle, 10) [WinAPI.ForegroundWindow]::ShowWindowAsync($_.MainWindowHandle, 10)
@ -12068,9 +12068,6 @@ public static extern bool SetForegroundWindow(IntPtr hWnd);
.NOTES .NOTES
The extension can be installed without Microsoft account The extension can be installed without Microsoft account
.NOTES
HEVC Video Extension is already installed in Windows 11 22H2 by default
.NOTES .NOTES
Current user Current user
#> #>
@ -12157,10 +12154,9 @@ function HEVC
} }
$Raw = Invoke-WebRequest @Parameters $Raw = Invoke-WebRequest @Parameters
# Parsing the page # Get a temp URL
$Raw | Select-String -Pattern '<tr style.*<a href=\"(?<url>.*)"\s.*>(?<text>.*)<\/a>' -AllMatches | ForEach-Object -Process {$_.Matches} | Where-Object -FilterScript {$_.Value -like "*HEVCVideoExtension*.appxbundle*"} | ForEach-Object -Process { $TempURL = $Raw.Links.href | Sort-Object -Property Length -Descending | Select-Object -First 1
$TempURL = ($_.Groups | Select-Object -Index 1).Value $HEVCPackageName = ($Raw.Links.outerHTML | Where-Object -FilterScript {$_ -match "appxbundle"}).Split("_") | Select-Object -Index 1
$HEVCPackageName = ($_.Groups | Select-Object -Index 2).Value.Split("_") | Select-Object -Index 1
# Installing "HEVC Video Extensions from Device Manufacturer" # Installing "HEVC Video Extensions from Device Manufacturer"
if ([System.Version]$HEVCPackageName -gt [System.Version](Get-AppxPackage -Name Microsoft.HEVCVideoExtension).Version) if ([System.Version]$HEVCPackageName -gt [System.Version](Get-AppxPackage -Name Microsoft.HEVCVideoExtension).Version)
@ -12183,6 +12179,10 @@ function HEVC
Add-AppxPackage -Path "$DownloadsFolder\Microsoft.HEVCVideoExtension_8wekyb3d8bbwe.appx" -Verbose Add-AppxPackage -Path "$DownloadsFolder\Microsoft.HEVCVideoExtension_8wekyb3d8bbwe.appx" -Verbose
Remove-Item -Path "$DownloadsFolder\Microsoft.HEVCVideoExtension_8wekyb3d8bbwe.appx" -Force Remove-Item -Path "$DownloadsFolder\Microsoft.HEVCVideoExtension_8wekyb3d8bbwe.appx" -Force
} }
else
{
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
} }
} }
catch [System.Net.WebException] catch [System.Net.WebException]

Loading…
Cancel
Save