Browse Source

Fixed Export-Associations function

pull/627/head
Dmitry Nefedov 4 weeks ago
parent
commit
c6a4018f90
  1. 80
      src/Sophia_Script_for_Windows_10/Module/Sophia.psm1
  2. 9
      src/Sophia_Script_for_Windows_10/Sophia.ps1
  3. 29
      src/Sophia_Script_for_Windows_10_LTSC_2019/Module/Sophia.psm1
  4. 1
      src/Sophia_Script_for_Windows_10_LTSC_2019/Sophia.ps1
  5. 29
      src/Sophia_Script_for_Windows_10_LTSC_2021/Module/Sophia.psm1
  6. 1
      src/Sophia_Script_for_Windows_10_LTSC_2021/Sophia.ps1
  7. 80
      src/Sophia_Script_for_Windows_10_PowerShell_7/Module/Sophia.psm1
  8. 9
      src/Sophia_Script_for_Windows_10_PowerShell_7/Sophia.ps1
  9. 29
      src/Sophia_Script_for_Windows_11/Module/Sophia.psm1
  10. 29
      src/Sophia_Script_for_Windows_11_LTSC_2024/Module/Sophia.psm1
  11. 29
      src/Sophia_Script_for_Windows_11_PowerShell_7/Module/Sophia.psm1

80
src/Sophia_Script_for_Windows_10/Module/Sophia.psm1

@ -2368,57 +2368,6 @@ function BingSearch
}
}
}
<#
.SYNOPSIS
Microsoft account-related notifications on Start Menu
.PARAMETER Hide
Do not show Microsoft account-related notifications on Start Menu in Start menu
.PARAMETER Show
Show Microsoft account-related notifications on Start Menu in Start menu
.EXAMPLE
StartAccountNotifications -Hide
.EXAMPLE
StartAccountNotifications -Show
.NOTES
Current user
#>
function StartAccountNotifications
{
param
(
[Parameter(
Mandatory = $true,
ParameterSetName = "Hide"
)]
[switch]
$Hide,
[Parameter(
Mandatory = $true,
ParameterSetName = "Show"
)]
[switch]
$Show
)
switch ($PSCmdlet.ParameterSetName)
{
"Hide"
{
New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name Start_AccountNotifications -PropertyType DWord -Value 0 -Force
}
"Show"
{
Remove-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name Start_AccountNotifications -Force -ErrorAction Ignore
}
}
}
#endregion Privacy & Telemetry
#region UI & Personalization
@ -9666,9 +9615,12 @@ function Export-Associations
[xml]$XML = Get-Content -Path "$env:TEMP\Application_Associations.xml" -Encoding UTF8 -Force
$XML.DefaultAssociations.Association | ForEach-Object -Process {
# Clear varibale not to begin double "\" char
$ProgramPath, $Icon = $null
if ($AppxProgIds -contains $_.ProgId)
{
# if ProgId is a UWP app
# ProgId is a UWP app
# ProgrammPath
if (Test-Path -Path "HKCU:\Software\Classes\$($_.ProgId)\Shell\Open\Command")
{
@ -9818,8 +9770,6 @@ function Export-Associations
$AllJSON += $JSON
}
Clear-Variable -Name ProgramPath, Icon -ErrorAction Ignore
# Save in UTF-8 without BOM
$AllJSON | ConvertTo-Json | Set-Content -Path "$PSScriptRoot\..\Application_Associations.json" -Encoding Default -Force
@ -14200,14 +14150,24 @@ function CABInstallContext
{
"Show"
{
if (-not (Test-Path -Path Registry::HKEY_CLASSES_ROOT\CABFolder\Shell\runas\Command))
if ([Microsoft.Win32.Registry]::GetValue("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.cab\UserChoice", "ProgId", $null) -eq "CABFolder")
{
New-Item -Path Registry::HKEY_CLASSES_ROOT\CABFolder\Shell\runas\Command -Force
if (-not (Test-Path -Path Registry::HKEY_CLASSES_ROOT\CABFolder\Shell\runas\Command))
{
New-Item -Path Registry::HKEY_CLASSES_ROOT\CABFolder\Shell\runas\Command -Force
}
New-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\CABFolder\Shell\runas\Command -Name "(default)" -PropertyType String -Value "cmd /c DISM.exe /Online /Add-Package /PackagePath:`"%1`" /NoRestart & pause" -Force
New-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\CABFolder\Shell\runas -Name MUIVerb -PropertyType String -Value "@shell32.dll,-10210" -Force
New-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\CABFolder\Shell\runas -Name HasLUAShield -PropertyType String -Value "" -Force
}
else
{
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message ($Localization.Skipped -f $MyInvocation.Line.Trim()) -Verbose
Write-Error -Message ($Localization.Skipped -f $MyInvocation.Line.Trim()) -ErrorAction SilentlyContinue
return
}
$Value = "cmd /c DISM.exe /Online /Add-Package /PackagePath:`"%1`" /NoRestart & pause"
New-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\CABFolder\Shell\runas\Command -Name "(default)" -PropertyType String -Value $Value -Force
New-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\CABFolder\Shell\runas -Name MUIVerb -PropertyType String -Value "@shell32.dll,-10210" -Force
New-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\CABFolder\Shell\runas -Name HasLUAShield -PropertyType String -Value "" -Force
}
"Hide"
{

9
src/Sophia_Script_for_Windows_10/Sophia.ps1

@ -304,14 +304,6 @@ BingSearch -Disable
# Enable Bing search in Start Menu (default value)
# Включить поиск через Bing в меню "Пуск" (значение по умолчанию)
# BingSearch -Enable
# Do not show Microsoft account-related notifications on Start Menu in Start menu
# Не показывать в меню "Пуск" уведомления, связанные с учетной записью Microsoft
StartAccountNotifications -Hide
# Show Microsoft account-related notifications on Start Menu in Start menu (default value)
# Переодически показывать в меню "Пуск" уведомления, связанные с учетной записью Microsoft (значение по умолчанию)
# StartAccountNotifications -Show
#endregion Privacy & Telemetry
#region UI & Personalization
@ -405,6 +397,7 @@ RecycleBinDeleteConfirmation -Enable
# Hide user folders in "This PC"
# Скрыть пользовательские папки в "Этот компьютер"
UserFolders -ThreeDObjects Hide
# UserFolders -ThreeDObjects Hide -Desktop Hide -Documents Hide -Downloads Hide -Music Hide -Pictures Hide -Videos Hide
# Show user folders in "This PC" (default value)

29
src/Sophia_Script_for_Windows_10_LTSC_2019/Module/Sophia.psm1

@ -7955,9 +7955,12 @@ function Export-Associations
[xml]$XML = Get-Content -Path "$env:TEMP\Application_Associations.xml" -Encoding UTF8 -Force
$XML.DefaultAssociations.Association | ForEach-Object -Process {
# Clear varibale not to begin double "\" char
$ProgramPath, $Icon = $null
if ($AppxProgIds -contains $_.ProgId)
{
# if ProgId is a UWP app
# ProgId is a UWP app
# ProgrammPath
if (Test-Path -Path "HKCU:\Software\Classes\$($_.ProgId)\Shell\Open\Command")
{
@ -8107,8 +8110,6 @@ function Export-Associations
$AllJSON += $JSON
}
Clear-Variable -Name ProgramPath, Icon -ErrorAction Ignore
# Save in UTF-8 without BOM
$AllJSON | ConvertTo-Json | Set-Content -Path "$PSScriptRoot\..\Application_Associations.json" -Encoding Default -Force
@ -10837,14 +10838,24 @@ function CABInstallContext
{
"Show"
{
if (-not (Test-Path -Path Registry::HKEY_CLASSES_ROOT\CABFolder\Shell\runas\Command))
if ([Microsoft.Win32.Registry]::GetValue("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.cab\UserChoice", "ProgId", $null) -eq "CABFolder")
{
if (-not (Test-Path -Path Registry::HKEY_CLASSES_ROOT\CABFolder\Shell\runas\Command))
{
New-Item -Path Registry::HKEY_CLASSES_ROOT\CABFolder\Shell\runas\Command -Force
}
New-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\CABFolder\Shell\runas\Command -Name "(default)" -PropertyType String -Value "cmd /c DISM.exe /Online /Add-Package /PackagePath:`"%1`" /NoRestart & pause" -Force
New-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\CABFolder\Shell\runas -Name MUIVerb -PropertyType String -Value "@shell32.dll,-10210" -Force
New-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\CABFolder\Shell\runas -Name HasLUAShield -PropertyType String -Value "" -Force
}
else
{
New-Item -Path Registry::HKEY_CLASSES_ROOT\CABFolder\Shell\runas\Command -Force
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message ($Localization.Skipped -f $MyInvocation.Line.Trim()) -Verbose
Write-Error -Message ($Localization.Skipped -f $MyInvocation.Line.Trim()) -ErrorAction SilentlyContinue
return
}
$Value = "cmd /c DISM.exe /Online /Add-Package /PackagePath:`"%1`" /NoRestart & pause"
New-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\CABFolder\Shell\runas\Command -Name "(default)" -PropertyType String -Value $Value -Force
New-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\CABFolder\Shell\runas -Name MUIVerb -PropertyType String -Value "@shell32.dll,-10210" -Force
New-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\CABFolder\Shell\runas -Name HasLUAShield -PropertyType String -Value "" -Force
}
"Hide"
{

1
src/Sophia_Script_for_Windows_10_LTSC_2019/Sophia.ps1

@ -326,6 +326,7 @@ RecycleBinDeleteConfirmation -Enable
# Hide user folders in "This PC"
# Скрыть пользовательские папки в "Этот компьютер"
UserFolders -ThreeDObjects Hide
# UserFolders -ThreeDObjects Hide -Desktop Hide -Documents Hide -Downloads Hide -Music Hide -Pictures Hide -Videos Hide
# Show user folders in "This PC" (default value)

29
src/Sophia_Script_for_Windows_10_LTSC_2021/Module/Sophia.psm1

@ -8592,9 +8592,12 @@ function Export-Associations
[xml]$XML = Get-Content -Path "$env:TEMP\Application_Associations.xml" -Encoding UTF8 -Force
$XML.DefaultAssociations.Association | ForEach-Object -Process {
# Clear varibale not to begin double "\" char
$ProgramPath, $Icon = $null
if ($AppxProgIds -contains $_.ProgId)
{
# if ProgId is a UWP app
# ProgId is a UWP app
# ProgrammPath
if (Test-Path -Path "HKCU:\Software\Classes\$($_.ProgId)\Shell\Open\Command")
{
@ -8744,8 +8747,6 @@ function Export-Associations
$AllJSON += $JSON
}
Clear-Variable -Name ProgramPath, Icon -ErrorAction Ignore
# Save in UTF-8 without BOM
$AllJSON | ConvertTo-Json | Set-Content -Path "$PSScriptRoot\..\Application_Associations.json" -Encoding Default -Force
@ -12156,14 +12157,24 @@ function CABInstallContext
{
"Show"
{
if (-not (Test-Path -Path Registry::HKEY_CLASSES_ROOT\CABFolder\Shell\runas\Command))
if ([Microsoft.Win32.Registry]::GetValue("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.cab\UserChoice", "ProgId", $null) -eq "CABFolder")
{
if (-not (Test-Path -Path Registry::HKEY_CLASSES_ROOT\CABFolder\Shell\runas\Command))
{
New-Item -Path Registry::HKEY_CLASSES_ROOT\CABFolder\Shell\runas\Command -Force
}
New-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\CABFolder\Shell\runas\Command -Name "(default)" -PropertyType String -Value "cmd /c DISM.exe /Online /Add-Package /PackagePath:`"%1`" /NoRestart & pause" -Force
New-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\CABFolder\Shell\runas -Name MUIVerb -PropertyType String -Value "@shell32.dll,-10210" -Force
New-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\CABFolder\Shell\runas -Name HasLUAShield -PropertyType String -Value "" -Force
}
else
{
New-Item -Path Registry::HKEY_CLASSES_ROOT\CABFolder\Shell\runas\Command -Force
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message ($Localization.Skipped -f $MyInvocation.Line.Trim()) -Verbose
Write-Error -Message ($Localization.Skipped -f $MyInvocation.Line.Trim()) -ErrorAction SilentlyContinue
return
}
$Value = "cmd /c DISM.exe /Online /Add-Package /PackagePath:`"%1`" /NoRestart & pause"
New-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\CABFolder\Shell\runas\Command -Name "(default)" -PropertyType String -Value $Value -Force
New-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\CABFolder\Shell\runas -Name MUIVerb -PropertyType String -Value "@shell32.dll,-10210" -Force
New-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\CABFolder\Shell\runas -Name HasLUAShield -PropertyType String -Value "" -Force
}
"Hide"
{

1
src/Sophia_Script_for_Windows_10_LTSC_2021/Sophia.ps1

@ -358,6 +358,7 @@ RecycleBinDeleteConfirmation -Enable
# Hide user folders in "This PC"
# Скрыть пользовательские папки в "Этот компьютер"
UserFolders -ThreeDObjects Hide
# UserFolders -ThreeDObjects Hide -Desktop Hide -Documents Hide -Downloads Hide -Music Hide -Pictures Hide -Videos Hide
# Show user folders in "This PC" (default value)

80
src/Sophia_Script_for_Windows_10_PowerShell_7/Module/Sophia.psm1

@ -2400,57 +2400,6 @@ function BingSearch
}
}
}
<#
.SYNOPSIS
Microsoft account-related notifications on Start Menu
.PARAMETER Hide
Do not show Microsoft account-related notifications on Start Menu in Start menu
.PARAMETER Show
Show Microsoft account-related notifications on Start Menu in Start menu
.EXAMPLE
StartAccountNotifications -Hide
.EXAMPLE
StartAccountNotifications -Show
.NOTES
Current user
#>
function StartAccountNotifications
{
param
(
[Parameter(
Mandatory = $true,
ParameterSetName = "Hide"
)]
[switch]
$Hide,
[Parameter(
Mandatory = $true,
ParameterSetName = "Show"
)]
[switch]
$Show
)
switch ($PSCmdlet.ParameterSetName)
{
"Hide"
{
New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name Start_AccountNotifications -PropertyType DWord -Value 0 -Force
}
"Show"
{
Remove-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name Start_AccountNotifications -Force -ErrorAction Ignore
}
}
}
#endregion Privacy & Telemetry
#region UI & Personalization
@ -9700,9 +9649,12 @@ function Export-Associations
[xml]$XML = Get-Content -Path "$env:TEMP\Application_Associations.xml" -Encoding utf8 -Force
$XML.DefaultAssociations.Association | ForEach-Object -Process {
# Clear varibale not to begin double "\" char
$ProgramPath, $Icon = $null
if ($AppxProgIds -contains $_.ProgId)
{
# if ProgId is a UWP app
# ProgId is a UWP app
# ProgrammPath
if (Test-Path -Path "HKCU:\Software\Classes\$($_.ProgId)\Shell\Open\Command")
{
@ -9852,8 +9804,6 @@ function Export-Associations
$AllJSON += $JSON
}
Clear-Variable -Name ProgramPath, Icon -ErrorAction Ignore
# Save in UTF-8 without BOM
$AllJSON | ConvertTo-Json | Set-Content -Path "$PSScriptRoot\..\Application_Associations.json" -Encoding utf8NoBOM -Force
@ -14244,14 +14194,24 @@ function CABInstallContext
{
"Show"
{
if (-not (Test-Path -Path Registry::HKEY_CLASSES_ROOT\CABFolder\Shell\runas\Command))
if ([Microsoft.Win32.Registry]::GetValue("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.cab\UserChoice", "ProgId", $null) -eq "CABFolder")
{
New-Item -Path Registry::HKEY_CLASSES_ROOT\CABFolder\Shell\runas\Command -Force
if (-not (Test-Path -Path Registry::HKEY_CLASSES_ROOT\CABFolder\Shell\runas\Command))
{
New-Item -Path Registry::HKEY_CLASSES_ROOT\CABFolder\Shell\runas\Command -Force
}
New-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\CABFolder\Shell\runas\Command -Name "(default)" -PropertyType String -Value "cmd /c DISM.exe /Online /Add-Package /PackagePath:`"%1`" /NoRestart & pause" -Force
New-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\CABFolder\Shell\runas -Name MUIVerb -PropertyType String -Value "@shell32.dll,-10210" -Force
New-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\CABFolder\Shell\runas -Name HasLUAShield -PropertyType String -Value "" -Force
}
else
{
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message ($Localization.Skipped -f $MyInvocation.Line.Trim()) -Verbose
Write-Error -Message ($Localization.Skipped -f $MyInvocation.Line.Trim()) -ErrorAction SilentlyContinue
return
}
$Value = "cmd /c DISM.exe /Online /Add-Package /PackagePath:`"%1`" /NoRestart & pause"
New-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\CABFolder\Shell\runas\Command -Name "(default)" -PropertyType String -Value $Value -Force
New-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\CABFolder\Shell\runas -Name MUIVerb -PropertyType String -Value "@shell32.dll,-10210" -Force
New-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\CABFolder\Shell\runas -Name HasLUAShield -PropertyType String -Value "" -Force
}
"Hide"
{

9
src/Sophia_Script_for_Windows_10_PowerShell_7/Sophia.ps1

@ -308,14 +308,6 @@ BingSearch -Disable
# Enable Bing search in Start Menu (default value)
# Включить поиск через Bing в меню "Пуск" (значение по умолчанию)
# BingSearch -Enable
# Do not show Microsoft account-related notifications on Start Menu in Start menu
# Не показывать в меню "Пуск" уведомления, связанные с учетной записью Microsoft
StartAccountNotifications -Hide
# Show Microsoft account-related notifications on Start Menu in Start menu (default value)
# Переодически показывать в меню "Пуск" уведомления, связанные с учетной записью Microsoft (значение по умолчанию)
# StartAccountNotifications -Show
#endregion Privacy & Telemetry
#region UI & Personalization
@ -409,6 +401,7 @@ RecycleBinDeleteConfirmation -Enable
# Hide user folders in "This PC"
# Скрыть пользовательские папки в "Этот компьютер"
UserFolders -ThreeDObjects Hide
# UserFolders -ThreeDObjects Hide -Desktop Hide -Documents Hide -Downloads Hide -Music Hide -Pictures Hide -Videos Hide
# Show user folders in "This PC" (default value)

29
src/Sophia_Script_for_Windows_11/Module/Sophia.psm1

@ -9219,9 +9219,12 @@ function Export-Associations
[xml]$XML = Get-Content -Path "$env:TEMP\Application_Associations.xml" -Encoding UTF8 -Force
$XML.DefaultAssociations.Association | ForEach-Object -Process {
# Clear varibale not to begin double "\" char
$ProgramPath, $Icon = $null
if ($AppxProgIds -contains $_.ProgId)
{
# if ProgId is a UWP app
# ProgId is a UWP app
# ProgrammPath
if (Test-Path -Path "HKCU:\Software\Classes\$($_.ProgId)\Shell\Open\Command")
{
@ -9371,8 +9374,6 @@ function Export-Associations
$AllJSON += $JSON
}
Clear-Variable -Name ProgramPath, Icon -ErrorAction Ignore
# Save in UTF-8 without BOM
$AllJSON | ConvertTo-Json | Set-Content -Path "$PSScriptRoot\..\Application_Associations.json" -Encoding Default -Force
@ -13326,14 +13327,24 @@ function CABInstallContext
{
"Show"
{
if (-not (Test-Path -Path Registry::HKEY_CLASSES_ROOT\CABFolder\Shell\runas\Command))
if ([Microsoft.Win32.Registry]::GetValue("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.cab\UserChoice", "ProgId", $null) -eq "CABFolder")
{
if (-not (Test-Path -Path Registry::HKEY_CLASSES_ROOT\CABFolder\Shell\runas\Command))
{
New-Item -Path Registry::HKEY_CLASSES_ROOT\CABFolder\Shell\runas\Command -Force
}
New-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\CABFolder\Shell\runas\Command -Name "(default)" -PropertyType String -Value "cmd /c DISM.exe /Online /Add-Package /PackagePath:`"%1`" /NoRestart & pause" -Force
New-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\CABFolder\Shell\runas -Name MUIVerb -PropertyType String -Value "@shell32.dll,-10210" -Force
New-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\CABFolder\Shell\runas -Name HasLUAShield -PropertyType String -Value "" -Force
}
else
{
New-Item -Path Registry::HKEY_CLASSES_ROOT\CABFolder\Shell\runas\Command -Force
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message ($Localization.Skipped -f $MyInvocation.Line.Trim()) -Verbose
Write-Error -Message ($Localization.Skipped -f $MyInvocation.Line.Trim()) -ErrorAction SilentlyContinue
return
}
$Value = "cmd /c DISM.exe /Online /Add-Package /PackagePath:`"%1`" /NoRestart & pause"
New-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\CABFolder\Shell\runas\Command -Name "(default)" -PropertyType String -Value $Value -Force
New-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\CABFolder\Shell\runas -Name MUIVerb -PropertyType String -Value "@shell32.dll,-10210" -Force
New-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\CABFolder\Shell\runas -Name HasLUAShield -PropertyType String -Value "" -Force
}
"Hide"
{

29
src/Sophia_Script_for_Windows_11_LTSC_2024/Module/Sophia.psm1

@ -8747,9 +8747,12 @@ function Export-Associations
[xml]$XML = Get-Content -Path "$env:TEMP\Application_Associations.xml" -Encoding UTF8 -Force
$XML.DefaultAssociations.Association | ForEach-Object -Process {
# Clear varibale not to begin double "\" char
$ProgramPath, $Icon = $null
if ($AppxProgIds -contains $_.ProgId)
{
# if ProgId is a UWP app
# ProgId is a UWP app
# ProgrammPath
if (Test-Path -Path "HKCU:\Software\Classes\$($_.ProgId)\Shell\Open\Command")
{
@ -8899,8 +8902,6 @@ function Export-Associations
$AllJSON += $JSON
}
Clear-Variable -Name ProgramPath, Icon -ErrorAction Ignore
# Save in UTF-8 without BOM
$AllJSON | ConvertTo-Json | Set-Content -Path "$PSScriptRoot\..\Application_Associations.json" -Encoding Default -Force
@ -12651,14 +12652,24 @@ function CABInstallContext
{
"Show"
{
if (-not (Test-Path -Path Registry::HKEY_CLASSES_ROOT\CABFolder\Shell\runas\Command))
if ([Microsoft.Win32.Registry]::GetValue("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.cab\UserChoice", "ProgId", $null) -eq "CABFolder")
{
if (-not (Test-Path -Path Registry::HKEY_CLASSES_ROOT\CABFolder\Shell\runas\Command))
{
New-Item -Path Registry::HKEY_CLASSES_ROOT\CABFolder\Shell\runas\Command -Force
}
New-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\CABFolder\Shell\runas\Command -Name "(default)" -PropertyType String -Value "cmd /c DISM.exe /Online /Add-Package /PackagePath:`"%1`" /NoRestart & pause" -Force
New-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\CABFolder\Shell\runas -Name MUIVerb -PropertyType String -Value "@shell32.dll,-10210" -Force
New-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\CABFolder\Shell\runas -Name HasLUAShield -PropertyType String -Value "" -Force
}
else
{
New-Item -Path Registry::HKEY_CLASSES_ROOT\CABFolder\Shell\runas\Command -Force
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message ($Localization.Skipped -f $MyInvocation.Line.Trim()) -Verbose
Write-Error -Message ($Localization.Skipped -f $MyInvocation.Line.Trim()) -ErrorAction SilentlyContinue
return
}
$Value = "cmd /c DISM.exe /Online /Add-Package /PackagePath:`"%1`" /NoRestart & pause"
New-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\CABFolder\Shell\runas\Command -Name "(default)" -PropertyType String -Value $Value -Force
New-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\CABFolder\Shell\runas -Name MUIVerb -PropertyType String -Value "@shell32.dll,-10210" -Force
New-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\CABFolder\Shell\runas -Name HasLUAShield -PropertyType String -Value "" -Force
}
"Hide"
{

29
src/Sophia_Script_for_Windows_11_PowerShell_7/Module/Sophia.psm1

@ -9253,9 +9253,12 @@ function Export-Associations
[xml]$XML = Get-Content -Path "$env:TEMP\Application_Associations.xml" -Encoding UTF8 -Force
$XML.DefaultAssociations.Association | ForEach-Object -Process {
# Clear varibale not to begin double "\" char
$ProgramPath, $Icon = $null
if ($AppxProgIds -contains $_.ProgId)
{
# if ProgId is a UWP app
# ProgId is a UWP app
# ProgrammPath
if (Test-Path -Path "HKCU:\Software\Classes\$($_.ProgId)\Shell\Open\Command")
{
@ -9405,8 +9408,6 @@ function Export-Associations
$AllJSON += $JSON
}
Clear-Variable -Name ProgramPath, Icon -ErrorAction Ignore
# Save in UTF-8 without BOM
$AllJSON | ConvertTo-Json | Set-Content -Path "$PSScriptRoot\..\Application_Associations.json" -Encoding utf8NoBOM -Force
@ -13370,14 +13371,24 @@ function CABInstallContext
{
"Show"
{
if (-not (Test-Path -Path Registry::HKEY_CLASSES_ROOT\CABFolder\Shell\runas\Command))
if ([Microsoft.Win32.Registry]::GetValue("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.cab\UserChoice", "ProgId", $null) -eq "CABFolder")
{
if (-not (Test-Path -Path Registry::HKEY_CLASSES_ROOT\CABFolder\Shell\runas\Command))
{
New-Item -Path Registry::HKEY_CLASSES_ROOT\CABFolder\Shell\runas\Command -Force
}
New-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\CABFolder\Shell\runas\Command -Name "(default)" -PropertyType String -Value "cmd /c DISM.exe /Online /Add-Package /PackagePath:`"%1`" /NoRestart & pause" -Force
New-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\CABFolder\Shell\runas -Name MUIVerb -PropertyType String -Value "@shell32.dll,-10210" -Force
New-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\CABFolder\Shell\runas -Name HasLUAShield -PropertyType String -Value "" -Force
}
else
{
New-Item -Path Registry::HKEY_CLASSES_ROOT\CABFolder\Shell\runas\Command -Force
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message ($Localization.Skipped -f $MyInvocation.Line.Trim()) -Verbose
Write-Error -Message ($Localization.Skipped -f $MyInvocation.Line.Trim()) -ErrorAction SilentlyContinue
return
}
$Value = "cmd /c DISM.exe /Online /Add-Package /PackagePath:`"%1`" /NoRestart & pause"
New-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\CABFolder\Shell\runas\Command -Name "(default)" -PropertyType String -Value $Value -Force
New-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\CABFolder\Shell\runas -Name MUIVerb -PropertyType String -Value "@shell32.dll,-10210" -Force
New-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\CABFolder\Shell\runas -Name HasLUAShield -PropertyType String -Value "" -Force
}
"Hide"
{

Loading…
Cancel
Save