Browse Source

Improved Set-Association function

pull/455/head
Dmitry Nefedov 1 year ago
parent
commit
31152cbfed
  1. 75
      src/Sophia_Script_for_Windows_10/Module/Sophia.psm1
  2. 66
      src/Sophia_Script_for_Windows_10_LTSC_2019/Module/Sophia.psm1
  3. 66
      src/Sophia_Script_for_Windows_10_LTSC_2021/Module/Sophia.psm1
  4. 75
      src/Sophia_Script_for_Windows_10_PowerShell_7/Module/Sophia.psm1
  5. 66
      src/Sophia_Script_for_Windows_11/Module/Sophia.psm1
  6. 2
      src/Sophia_Script_for_Windows_11/Sophia.ps1
  7. 66
      src/Sophia_Script_for_Windows_11_PowerShell_7/Module/Sophia.psm1

75
src/Sophia_Script_for_Windows_10/Module/Sophia.psm1

@ -4535,7 +4535,12 @@ public static bool MarkFileDelete (string sourcefile)
}
Remove-ItemProperty -Path HKCU:\Environment -Name OneDrive, OneDriveConsumer -Force -ErrorAction Ignore
Remove-Item -Path HKCU:\Software\Microsoft\OneDrive, HKLM:\SOFTWARE\WOW6432Node\Microsoft\OneDrive, "$env:ProgramData\Microsoft OneDrive", $env:SystemDrive\OneDriveTemp -Recurse -Force -ErrorAction Ignore
$Path = @(
"HKCU:\Software\Microsoft\OneDrive",
"$env:ProgramData\Microsoft OneDrive",
"$env:SystemDrive\OneDriveTemp"
)
Remove-Item -Path $Path -Recurse -Force -ErrorAction Ignore
Unregister-ScheduledTask -TaskName *OneDrive* -Confirm:$false -ErrorAction Ignore
# Getting the OneDrive folder path
@ -4587,7 +4592,7 @@ public static bool MarkFileDelete (string sourcefile)
return
}
if (Test-Path -Path $env:SystemRoot\System32\OneDriveSetup.exe)
if (Test-Path -Path $env:SystemRoot\SysWOW64\OneDriveSetup.exe)
{
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.OneDriveInstalling -Verbose
@ -8509,6 +8514,15 @@ function Set-Association
$ProgramPath = [System.Environment]::ExpandEnvironmentVariables($ProgramPath)
if (-not (Test-Path -Path $ProgramPath))
{
Write-Verbose -Message $Localization.Skipped -Verbose
Write-Error -Message $Localization.NoInternetConnection -ErrorAction SilentlyContinue
Write-Error -Message ($Localization.RestartFunction -f $MyInvocation.Line) -ErrorAction SilentlyContinue
return
}
if ($Icon)
{
$Icon = [System.Environment]::ExpandEnvironmentVariables($Icon)
@ -8804,23 +8818,27 @@ namespace RegistryUtils
$Extension
)
$OrigProgID = (Get-ItemProperty -Path "HKLM:\SOFTWARE\Classes\$Extension" -Name "(default)" -ErrorAction Ignore)."(default)"
if ($OrigProgID)
# Due to "Set-StrictMode -Version Latest" we have to check everything
if ((Test-Path -Path "HKLM:\SOFTWARE\Classes\$Extension") -and (Get-ItemProperty -Path "HKLM:\SOFTWARE\Classes\$Extension" -Name "(default)" -ErrorAction Ignore))
{
# Save possible ProgIds history with extension
New-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\ApplicationAssociationToasts" -Name "$ProgID_$Extension" -PropertyType DWord -Value 0 -Force
if ((Get-ItemProperty -Path "HKLM:\SOFTWARE\Classes\$Extension" -Name "(default)" -ErrorAction Ignore)."(default)")
{
# Save possible ProgIds history with extension
New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\ApplicationAssociationToasts -Name "$($ProgID)_$($Extension)" -PropertyType DWord -Value 0 -Force
}
}
$Name = "{0}_$Extension" -f (Split-Path -Path $ProgId -Leaf)
New-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\ApplicationAssociationToasts" -Name $Name -PropertyType DWord -Value 0 -Force
$Name = "{0}_$($Extension)" -f (Split-Path -Path $ProgId -Leaf)
New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\ApplicationAssociationToasts -Name $Name -PropertyType DWord -Value 0 -Force
if ("$ProgId_$Extension" -ne $Name)
if ("$($ProgID)_$($Extension)" -ne $Name)
{
New-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\ApplicationAssociationToasts" -Name "$ProgId_$Extension" -PropertyType DWord -Value 0 -Force
New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\ApplicationAssociationToasts -Name "$($ProgID)_$($Extension)" -PropertyType DWord -Value 0 -Force
}
# If ProgId doesn't exist set the specified ProgId for the extensions
if (-not $OrigProgID)
# Due to "Set-StrictMode -Version Latest" we have to check everything
if (-not (Get-Variable -Name OrigProgID -ErrorAction Ignore))
{
if (-not (Test-Path -Path "HKCU:\Software\Classes\$Extension"))
{
@ -8837,7 +8855,8 @@ namespace RegistryUtils
New-ItemProperty -Path "HKCU:\Software\Classes\$Extension\OpenWithProgids" -Name $ProgId -PropertyType None -Value ([byte[]]@()) -Force
# Set the system ProgId to the extension parameters for the File Explorer to the possible options for the assignment, and if absent set the specified ProgId
if ($OrigProgID)
# Due to "Set-StrictMode -Version Latest" we have to check everything
if (Get-Variable -Name OrigProgID -ErrorAction Ignore)
{
if (-not (Test-Path -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\$Extension\OpenWithProgids"))
{
@ -8895,13 +8914,17 @@ namespace RegistryUtils
)
# If there is the system extension ProgId, write it to the already configured by default
if ((Get-ItemProperty -Path "HKLM:\SOFTWARE\Classes\$Extension" -Name "(default)" -ErrorAction Ignore)."(default)")
# Due to "Set-StrictMode -Version Latest" we have to check everything
if ((Test-Path -Path "HKLM:\SOFTWARE\Classes\$Extension") -and (Get-ItemProperty -Path "HKLM:\SOFTWARE\Classes\$Extension" -Name "(default)" -ErrorAction Ignore))
{
if (-not (Test-Path -Path Registry::HKEY_USERS\.DEFAULT\Software\Microsoft\Windows\CurrentVersion\FileAssociations\ProgIds))
if ((Get-ItemProperty -Path "HKLM:\SOFTWARE\Classes\$Extension" -Name "(default)" -ErrorAction Ignore)."(default)")
{
New-Item -Path Registry::HKEY_USERS\.DEFAULT\Software\Microsoft\Windows\CurrentVersion\FileAssociations\ProgIds -Force
if (-not (Test-Path -Path Registry::HKEY_USERS\.DEFAULT\Software\Microsoft\Windows\CurrentVersion\FileAssociations\ProgIds))
{
New-Item -Path Registry::HKEY_USERS\.DEFAULT\Software\Microsoft\Windows\CurrentVersion\FileAssociations\ProgIds -Force
}
New-ItemProperty -Path Registry::HKEY_USERS\.DEFAULT\Software\Microsoft\Windows\CurrentVersion\FileAssociations\ProgIds -Name "_$($Extension)" -PropertyType DWord -Value 1 -Force
}
New-ItemProperty -Path Registry::HKEY_USERS\.DEFAULT\Software\Microsoft\Windows\CurrentVersion\FileAssociations\ProgIds -Name "_$Extension" -PropertyType DWord -Value 1 -Force
}
# Setting 'NoOpenWith' for all registered the extension ProgIDs
@ -8929,12 +8952,24 @@ namespace RegistryUtils
}
}
$picture = (Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\KindMap" -Name $Extension -ErrorAction Ignore).$Extension
$PBrush = (Get-ItemProperty -Path "HKLM:\SOFTWARE\Classes\PBrush\CLSID" -Name "(default)" -ErrorAction Ignore)."(default)"
# Due to "Set-StrictMode -Version Latest" we have to check everything
if (Get-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\KindMap -Name $Extension -ErrorAction Ignore)
{
$picture = (Get-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\KindMap -Name $Extension -ErrorAction Ignore).$Extension
}
# Due to "Set-StrictMode -Version Latest" we have to check everything
if ((Test-Path -Path HKLM:\SOFTWARE\Classes\PBrush\CLSID) -and (Get-ItemProperty -Path HKLM:\SOFTWARE\Classes\PBrush\CLSID -Name "(default)" -ErrorAction Ignore))
{
$PBrush = (Get-ItemProperty -Path HKLM:\SOFTWARE\Classes\PBrush\CLSID -Name "(default)" -ErrorAction Ignore)."(default)"
}
if (($picture -eq "picture") -and $PBrush)
# Due to "Set-StrictMode -Version Latest" we have to check everything
if (Get-Variable -Name picture -ErrorAction Ignore)
{
New-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\ApplicationAssociationToasts" -Name "PBrush_$Extension" -PropertyType DWord -Value 0 -Force
if (($picture -eq "picture") -and $PBrush)
{
New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\ApplicationAssociationToasts -Name "PBrush_$($Extension)" -PropertyType DWord -Value 0 -Force
}
}
}

66
src/Sophia_Script_for_Windows_10_LTSC_2019/Module/Sophia.psm1

@ -6901,6 +6901,15 @@ function Set-Association
$ProgramPath = [System.Environment]::ExpandEnvironmentVariables($ProgramPath)
if (-not (Test-Path -Path $ProgramPath))
{
Write-Verbose -Message $Localization.Skipped -Verbose
Write-Error -Message $Localization.NoInternetConnection -ErrorAction SilentlyContinue
Write-Error -Message ($Localization.RestartFunction -f $MyInvocation.Line) -ErrorAction SilentlyContinue
return
}
if ($Icon)
{
$Icon = [System.Environment]::ExpandEnvironmentVariables($Icon)
@ -7196,23 +7205,27 @@ namespace RegistryUtils
$Extension
)
$OrigProgID = (Get-ItemProperty -Path "HKLM:\SOFTWARE\Classes\$Extension" -Name "(default)" -ErrorAction Ignore)."(default)"
if ($OrigProgID)
# Due to "Set-StrictMode -Version Latest" we have to check everything
if ((Test-Path -Path "HKLM:\SOFTWARE\Classes\$Extension") -and (Get-ItemProperty -Path "HKLM:\SOFTWARE\Classes\$Extension" -Name "(default)" -ErrorAction Ignore))
{
# Save possible ProgIds history with extension
New-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\ApplicationAssociationToasts" -Name "$ProgID_$Extension" -PropertyType DWord -Value 0 -Force
if ((Get-ItemProperty -Path "HKLM:\SOFTWARE\Classes\$Extension" -Name "(default)" -ErrorAction Ignore)."(default)")
{
# Save possible ProgIds history with extension
New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\ApplicationAssociationToasts -Name "$($ProgID)_$($Extension)" -PropertyType DWord -Value 0 -Force
}
}
$Name = "{0}_$Extension" -f (Split-Path -Path $ProgId -Leaf)
New-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\ApplicationAssociationToasts" -Name $Name -PropertyType DWord -Value 0 -Force
$Name = "{0}_$($Extension)" -f (Split-Path -Path $ProgId -Leaf)
New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\ApplicationAssociationToasts -Name $Name -PropertyType DWord -Value 0 -Force
if ("$ProgId_$Extension" -ne $Name)
if ("$($ProgID)_$($Extension)" -ne $Name)
{
New-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\ApplicationAssociationToasts" -Name "$ProgId_$Extension" -PropertyType DWord -Value 0 -Force
New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\ApplicationAssociationToasts -Name "$($ProgID)_$($Extension)" -PropertyType DWord -Value 0 -Force
}
# If ProgId doesn't exist set the specified ProgId for the extensions
if (-not $OrigProgID)
# Due to "Set-StrictMode -Version Latest" we have to check everything
if (-not (Get-Variable -Name OrigProgID -ErrorAction Ignore))
{
if (-not (Test-Path -Path "HKCU:\Software\Classes\$Extension"))
{
@ -7229,7 +7242,8 @@ namespace RegistryUtils
New-ItemProperty -Path "HKCU:\Software\Classes\$Extension\OpenWithProgids" -Name $ProgId -PropertyType None -Value ([byte[]]@()) -Force
# Set the system ProgId to the extension parameters for the File Explorer to the possible options for the assignment, and if absent set the specified ProgId
if ($OrigProgID)
# Due to "Set-StrictMode -Version Latest" we have to check everything
if (Get-Variable -Name OrigProgID -ErrorAction Ignore)
{
if (-not (Test-Path -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\$Extension\OpenWithProgids"))
{
@ -7287,13 +7301,17 @@ namespace RegistryUtils
)
# If there is the system extension ProgId, write it to the already configured by default
if ((Get-ItemProperty -Path "HKLM:\SOFTWARE\Classes\$Extension" -Name "(default)" -ErrorAction Ignore)."(default)")
# Due to "Set-StrictMode -Version Latest" we have to check everything
if ((Test-Path -Path "HKLM:\SOFTWARE\Classes\$Extension") -and (Get-ItemProperty -Path "HKLM:\SOFTWARE\Classes\$Extension" -Name "(default)" -ErrorAction Ignore))
{
if (-not (Test-Path -Path Registry::HKEY_USERS\.DEFAULT\Software\Microsoft\Windows\CurrentVersion\FileAssociations\ProgIds))
if ((Get-ItemProperty -Path "HKLM:\SOFTWARE\Classes\$Extension" -Name "(default)" -ErrorAction Ignore)."(default)")
{
New-Item -Path Registry::HKEY_USERS\.DEFAULT\Software\Microsoft\Windows\CurrentVersion\FileAssociations\ProgIds -Force
if (-not (Test-Path -Path Registry::HKEY_USERS\.DEFAULT\Software\Microsoft\Windows\CurrentVersion\FileAssociations\ProgIds))
{
New-Item -Path Registry::HKEY_USERS\.DEFAULT\Software\Microsoft\Windows\CurrentVersion\FileAssociations\ProgIds -Force
}
New-ItemProperty -Path Registry::HKEY_USERS\.DEFAULT\Software\Microsoft\Windows\CurrentVersion\FileAssociations\ProgIds -Name "_$($Extension)" -PropertyType DWord -Value 1 -Force
}
New-ItemProperty -Path Registry::HKEY_USERS\.DEFAULT\Software\Microsoft\Windows\CurrentVersion\FileAssociations\ProgIds -Name "_$Extension" -PropertyType DWord -Value 1 -Force
}
# Setting 'NoOpenWith' for all registered the extension ProgIDs
@ -7321,12 +7339,24 @@ namespace RegistryUtils
}
}
$picture = (Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\KindMap" -Name $Extension -ErrorAction Ignore).$Extension
$PBrush = (Get-ItemProperty -Path "HKLM:\SOFTWARE\Classes\PBrush\CLSID" -Name "(default)" -ErrorAction Ignore)."(default)"
# Due to "Set-StrictMode -Version Latest" we have to check everything
if (Get-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\KindMap -Name $Extension -ErrorAction Ignore)
{
$picture = (Get-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\KindMap -Name $Extension -ErrorAction Ignore).$Extension
}
# Due to "Set-StrictMode -Version Latest" we have to check everything
if ((Test-Path -Path HKLM:\SOFTWARE\Classes\PBrush\CLSID) -and (Get-ItemProperty -Path HKLM:\SOFTWARE\Classes\PBrush\CLSID -Name "(default)" -ErrorAction Ignore))
{
$PBrush = (Get-ItemProperty -Path HKLM:\SOFTWARE\Classes\PBrush\CLSID -Name "(default)" -ErrorAction Ignore)."(default)"
}
if (($picture -eq "picture") -and $PBrush)
# Due to "Set-StrictMode -Version Latest" we have to check everything
if (Get-Variable -Name picture -ErrorAction Ignore)
{
New-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\ApplicationAssociationToasts" -Name "PBrush_$Extension" -PropertyType DWord -Value 0 -Force
if (($picture -eq "picture") -and $PBrush)
{
New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\ApplicationAssociationToasts -Name "PBrush_$($Extension)" -PropertyType DWord -Value 0 -Force
}
}
}

66
src/Sophia_Script_for_Windows_10_LTSC_2021/Module/Sophia.psm1

@ -7526,6 +7526,15 @@ function Set-Association
$ProgramPath = [System.Environment]::ExpandEnvironmentVariables($ProgramPath)
if (-not (Test-Path -Path $ProgramPath))
{
Write-Verbose -Message $Localization.Skipped -Verbose
Write-Error -Message $Localization.NoInternetConnection -ErrorAction SilentlyContinue
Write-Error -Message ($Localization.RestartFunction -f $MyInvocation.Line) -ErrorAction SilentlyContinue
return
}
if ($Icon)
{
$Icon = [System.Environment]::ExpandEnvironmentVariables($Icon)
@ -7821,23 +7830,27 @@ namespace RegistryUtils
$Extension
)
$OrigProgID = (Get-ItemProperty -Path "HKLM:\SOFTWARE\Classes\$Extension" -Name "(default)" -ErrorAction Ignore)."(default)"
if ($OrigProgID)
# Due to "Set-StrictMode -Version Latest" we have to check everything
if ((Test-Path -Path "HKLM:\SOFTWARE\Classes\$Extension") -and (Get-ItemProperty -Path "HKLM:\SOFTWARE\Classes\$Extension" -Name "(default)" -ErrorAction Ignore))
{
# Save possible ProgIds history with extension
New-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\ApplicationAssociationToasts" -Name "$ProgID_$Extension" -PropertyType DWord -Value 0 -Force
if ((Get-ItemProperty -Path "HKLM:\SOFTWARE\Classes\$Extension" -Name "(default)" -ErrorAction Ignore)."(default)")
{
# Save possible ProgIds history with extension
New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\ApplicationAssociationToasts -Name "$($ProgID)_$($Extension)" -PropertyType DWord -Value 0 -Force
}
}
$Name = "{0}_$Extension" -f (Split-Path -Path $ProgId -Leaf)
New-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\ApplicationAssociationToasts" -Name $Name -PropertyType DWord -Value 0 -Force
$Name = "{0}_$($Extension)" -f (Split-Path -Path $ProgId -Leaf)
New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\ApplicationAssociationToasts -Name $Name -PropertyType DWord -Value 0 -Force
if ("$ProgId_$Extension" -ne $Name)
if ("$($ProgID)_$($Extension)" -ne $Name)
{
New-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\ApplicationAssociationToasts" -Name "$ProgId_$Extension" -PropertyType DWord -Value 0 -Force
New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\ApplicationAssociationToasts -Name "$($ProgID)_$($Extension)" -PropertyType DWord -Value 0 -Force
}
# If ProgId doesn't exist set the specified ProgId for the extensions
if (-not $OrigProgID)
# Due to "Set-StrictMode -Version Latest" we have to check everything
if (-not (Get-Variable -Name OrigProgID -ErrorAction Ignore))
{
if (-not (Test-Path -Path "HKCU:\Software\Classes\$Extension"))
{
@ -7854,7 +7867,8 @@ namespace RegistryUtils
New-ItemProperty -Path "HKCU:\Software\Classes\$Extension\OpenWithProgids" -Name $ProgId -PropertyType None -Value ([byte[]]@()) -Force
# Set the system ProgId to the extension parameters for the File Explorer to the possible options for the assignment, and if absent set the specified ProgId
if ($OrigProgID)
# Due to "Set-StrictMode -Version Latest" we have to check everything
if (Get-Variable -Name OrigProgID -ErrorAction Ignore)
{
if (-not (Test-Path -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\$Extension\OpenWithProgids"))
{
@ -7912,13 +7926,17 @@ namespace RegistryUtils
)
# If there is the system extension ProgId, write it to the already configured by default
if ((Get-ItemProperty -Path "HKLM:\SOFTWARE\Classes\$Extension" -Name "(default)" -ErrorAction Ignore)."(default)")
# Due to "Set-StrictMode -Version Latest" we have to check everything
if ((Test-Path -Path "HKLM:\SOFTWARE\Classes\$Extension") -and (Get-ItemProperty -Path "HKLM:\SOFTWARE\Classes\$Extension" -Name "(default)" -ErrorAction Ignore))
{
if (-not (Test-Path -Path Registry::HKEY_USERS\.DEFAULT\Software\Microsoft\Windows\CurrentVersion\FileAssociations\ProgIds))
if ((Get-ItemProperty -Path "HKLM:\SOFTWARE\Classes\$Extension" -Name "(default)" -ErrorAction Ignore)."(default)")
{
New-Item -Path Registry::HKEY_USERS\.DEFAULT\Software\Microsoft\Windows\CurrentVersion\FileAssociations\ProgIds -Force
if (-not (Test-Path -Path Registry::HKEY_USERS\.DEFAULT\Software\Microsoft\Windows\CurrentVersion\FileAssociations\ProgIds))
{
New-Item -Path Registry::HKEY_USERS\.DEFAULT\Software\Microsoft\Windows\CurrentVersion\FileAssociations\ProgIds -Force
}
New-ItemProperty -Path Registry::HKEY_USERS\.DEFAULT\Software\Microsoft\Windows\CurrentVersion\FileAssociations\ProgIds -Name "_$($Extension)" -PropertyType DWord -Value 1 -Force
}
New-ItemProperty -Path Registry::HKEY_USERS\.DEFAULT\Software\Microsoft\Windows\CurrentVersion\FileAssociations\ProgIds -Name "_$Extension" -PropertyType DWord -Value 1 -Force
}
# Setting 'NoOpenWith' for all registered the extension ProgIDs
@ -7946,12 +7964,24 @@ namespace RegistryUtils
}
}
$picture = (Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\KindMap" -Name $Extension -ErrorAction Ignore).$Extension
$PBrush = (Get-ItemProperty -Path "HKLM:\SOFTWARE\Classes\PBrush\CLSID" -Name "(default)" -ErrorAction Ignore)."(default)"
# Due to "Set-StrictMode -Version Latest" we have to check everything
if (Get-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\KindMap -Name $Extension -ErrorAction Ignore)
{
$picture = (Get-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\KindMap -Name $Extension -ErrorAction Ignore).$Extension
}
# Due to "Set-StrictMode -Version Latest" we have to check everything
if ((Test-Path -Path HKLM:\SOFTWARE\Classes\PBrush\CLSID) -and (Get-ItemProperty -Path HKLM:\SOFTWARE\Classes\PBrush\CLSID -Name "(default)" -ErrorAction Ignore))
{
$PBrush = (Get-ItemProperty -Path HKLM:\SOFTWARE\Classes\PBrush\CLSID -Name "(default)" -ErrorAction Ignore)."(default)"
}
if (($picture -eq "picture") -and $PBrush)
# Due to "Set-StrictMode -Version Latest" we have to check everything
if (Get-Variable -Name picture -ErrorAction Ignore)
{
New-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\ApplicationAssociationToasts" -Name "PBrush_$Extension" -PropertyType DWord -Value 0 -Force
if (($picture -eq "picture") -and $PBrush)
{
New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\ApplicationAssociationToasts -Name "PBrush_$($Extension)" -PropertyType DWord -Value 0 -Force
}
}
}

75
src/Sophia_Script_for_Windows_10_PowerShell_7/Module/Sophia.psm1

@ -4537,7 +4537,12 @@ public static bool MarkFileDelete (string sourcefile)
}
Remove-ItemProperty -Path HKCU:\Environment -Name OneDrive, OneDriveConsumer -Force -ErrorAction Ignore
Remove-Item -Path HKCU:\Software\Microsoft\OneDrive, HKLM:\SOFTWARE\WOW6432Node\Microsoft\OneDrive, "$env:ProgramData\Microsoft OneDrive", $env:SystemDrive\OneDriveTemp -Recurse -Force -ErrorAction Ignore
$Path = @(
"HKCU:\Software\Microsoft\OneDrive",
"$env:ProgramData\Microsoft OneDrive",
"$env:SystemDrive\OneDriveTemp"
)
Remove-Item -Path $Path -Recurse -Force -ErrorAction Ignore
Unregister-ScheduledTask -TaskName *OneDrive* -Confirm:$false -ErrorAction Ignore
# Getting the OneDrive folder path
@ -4589,7 +4594,7 @@ public static bool MarkFileDelete (string sourcefile)
return
}
if (Test-Path -Path $env:SystemRoot\System32\OneDriveSetup.exe)
if (Test-Path -Path $env:SystemRoot\SysWOW64\OneDriveSetup.exe)
{
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.OneDriveInstalling -Verbose
@ -8512,6 +8517,15 @@ function Set-Association
$ProgramPath = [System.Environment]::ExpandEnvironmentVariables($ProgramPath)
if (-not (Test-Path -Path $ProgramPath))
{
Write-Verbose -Message $Localization.Skipped -Verbose
Write-Error -Message $Localization.NoInternetConnection -ErrorAction SilentlyContinue
Write-Error -Message ($Localization.RestartFunction -f $MyInvocation.Line) -ErrorAction SilentlyContinue
return
}
if ($Icon)
{
$Icon = [System.Environment]::ExpandEnvironmentVariables($Icon)
@ -8807,23 +8821,27 @@ namespace RegistryUtils
$Extension
)
$OrigProgID = (Get-ItemProperty -Path "HKLM:\SOFTWARE\Classes\$Extension" -Name "(default)" -ErrorAction Ignore)."(default)"
if ($OrigProgID)
# Due to "Set-StrictMode -Version Latest" we have to check everything
if ((Test-Path -Path "HKLM:\SOFTWARE\Classes\$Extension") -and (Get-ItemProperty -Path "HKLM:\SOFTWARE\Classes\$Extension" -Name "(default)" -ErrorAction Ignore))
{
# Save possible ProgIds history with extension
New-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\ApplicationAssociationToasts" -Name "$ProgID_$Extension" -PropertyType DWord -Value 0 -Force
if ((Get-ItemProperty -Path "HKLM:\SOFTWARE\Classes\$Extension" -Name "(default)" -ErrorAction Ignore)."(default)")
{
# Save possible ProgIds history with extension
New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\ApplicationAssociationToasts -Name "$($ProgID)_$($Extension)" -PropertyType DWord -Value 0 -Force
}
}
$Name = "{0}_$Extension" -f (Split-Path -Path $ProgId -Leaf)
New-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\ApplicationAssociationToasts" -Name $Name -PropertyType DWord -Value 0 -Force
$Name = "{0}_$($Extension)" -f (Split-Path -Path $ProgId -Leaf)
New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\ApplicationAssociationToasts -Name $Name -PropertyType DWord -Value 0 -Force
if ("$ProgId_$Extension" -ne $Name)
if ("$($ProgID)_$($Extension)" -ne $Name)
{
New-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\ApplicationAssociationToasts" -Name "$ProgId_$Extension" -PropertyType DWord -Value 0 -Force
New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\ApplicationAssociationToasts -Name "$($ProgID)_$($Extension)" -PropertyType DWord -Value 0 -Force
}
# If ProgId doesn't exist set the specified ProgId for the extensions
if (-not $OrigProgID)
# Due to "Set-StrictMode -Version Latest" we have to check everything
if (-not (Get-Variable -Name OrigProgID -ErrorAction Ignore))
{
if (-not (Test-Path -Path "HKCU:\Software\Classes\$Extension"))
{
@ -8840,7 +8858,8 @@ namespace RegistryUtils
New-ItemProperty -Path "HKCU:\Software\Classes\$Extension\OpenWithProgids" -Name $ProgId -PropertyType None -Value ([byte[]]@()) -Force
# Set the system ProgId to the extension parameters for the File Explorer to the possible options for the assignment, and if absent set the specified ProgId
if ($OrigProgID)
# Due to "Set-StrictMode -Version Latest" we have to check everything
if (Get-Variable -Name OrigProgID -ErrorAction Ignore)
{
if (-not (Test-Path -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\$Extension\OpenWithProgids"))
{
@ -8898,13 +8917,17 @@ namespace RegistryUtils
)
# If there is the system extension ProgId, write it to the already configured by default
if ((Get-ItemProperty -Path "HKLM:\SOFTWARE\Classes\$Extension" -Name "(default)" -ErrorAction Ignore)."(default)")
# Due to "Set-StrictMode -Version Latest" we have to check everything
if ((Test-Path -Path "HKLM:\SOFTWARE\Classes\$Extension") -and (Get-ItemProperty -Path "HKLM:\SOFTWARE\Classes\$Extension" -Name "(default)" -ErrorAction Ignore))
{
if (-not (Test-Path -Path Registry::HKEY_USERS\.DEFAULT\Software\Microsoft\Windows\CurrentVersion\FileAssociations\ProgIds))
if ((Get-ItemProperty -Path "HKLM:\SOFTWARE\Classes\$Extension" -Name "(default)" -ErrorAction Ignore)."(default)")
{
New-Item -Path Registry::HKEY_USERS\.DEFAULT\Software\Microsoft\Windows\CurrentVersion\FileAssociations\ProgIds -Force
if (-not (Test-Path -Path Registry::HKEY_USERS\.DEFAULT\Software\Microsoft\Windows\CurrentVersion\FileAssociations\ProgIds))
{
New-Item -Path Registry::HKEY_USERS\.DEFAULT\Software\Microsoft\Windows\CurrentVersion\FileAssociations\ProgIds -Force
}
New-ItemProperty -Path Registry::HKEY_USERS\.DEFAULT\Software\Microsoft\Windows\CurrentVersion\FileAssociations\ProgIds -Name "_$($Extension)" -PropertyType DWord -Value 1 -Force
}
New-ItemProperty -Path Registry::HKEY_USERS\.DEFAULT\Software\Microsoft\Windows\CurrentVersion\FileAssociations\ProgIds -Name "_$Extension" -PropertyType DWord -Value 1 -Force
}
# Setting 'NoOpenWith' for all registered the extension ProgIDs
@ -8932,12 +8955,24 @@ namespace RegistryUtils
}
}
$picture = (Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\KindMap" -Name $Extension -ErrorAction Ignore).$Extension
$PBrush = (Get-ItemProperty -Path "HKLM:\SOFTWARE\Classes\PBrush\CLSID" -Name "(default)" -ErrorAction Ignore)."(default)"
# Due to "Set-StrictMode -Version Latest" we have to check everything
if (Get-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\KindMap -Name $Extension -ErrorAction Ignore)
{
$picture = (Get-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\KindMap -Name $Extension -ErrorAction Ignore).$Extension
}
# Due to "Set-StrictMode -Version Latest" we have to check everything
if ((Test-Path -Path HKLM:\SOFTWARE\Classes\PBrush\CLSID) -and (Get-ItemProperty -Path HKLM:\SOFTWARE\Classes\PBrush\CLSID -Name "(default)" -ErrorAction Ignore))
{
$PBrush = (Get-ItemProperty -Path HKLM:\SOFTWARE\Classes\PBrush\CLSID -Name "(default)" -ErrorAction Ignore)."(default)"
}
if (($picture -eq "picture") -and $PBrush)
# Due to "Set-StrictMode -Version Latest" we have to check everything
if (Get-Variable -Name picture -ErrorAction Ignore)
{
New-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\ApplicationAssociationToasts" -Name "PBrush_$Extension" -PropertyType DWord -Value 0 -Force
if (($picture -eq "picture") -and $PBrush)
{
New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\ApplicationAssociationToasts -Name "PBrush_$($Extension)" -PropertyType DWord -Value 0 -Force
}
}
}

66
src/Sophia_Script_for_Windows_11/Module/Sophia.psm1

@ -7994,6 +7994,15 @@ function Set-Association
$ProgramPath = [System.Environment]::ExpandEnvironmentVariables($ProgramPath)
if (-not (Test-Path -Path $ProgramPath))
{
Write-Verbose -Message $Localization.Skipped -Verbose
Write-Error -Message $Localization.NoInternetConnection -ErrorAction SilentlyContinue
Write-Error -Message ($Localization.RestartFunction -f $MyInvocation.Line) -ErrorAction SilentlyContinue
return
}
if ($Icon)
{
$Icon = [System.Environment]::ExpandEnvironmentVariables($Icon)
@ -8289,23 +8298,27 @@ namespace RegistryUtils
$Extension
)
$OrigProgID = (Get-ItemProperty -Path "HKLM:\SOFTWARE\Classes\$Extension" -Name "(default)" -ErrorAction Ignore)."(default)"
if ($OrigProgID)
# Due to "Set-StrictMode -Version Latest" we have to check everything
if ((Test-Path -Path "HKLM:\SOFTWARE\Classes\$Extension") -and (Get-ItemProperty -Path "HKLM:\SOFTWARE\Classes\$Extension" -Name "(default)" -ErrorAction Ignore))
{
# Save possible ProgIds history with extension
New-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\ApplicationAssociationToasts" -Name "$ProgID_$Extension" -PropertyType DWord -Value 0 -Force
if ((Get-ItemProperty -Path "HKLM:\SOFTWARE\Classes\$Extension" -Name "(default)" -ErrorAction Ignore)."(default)")
{
# Save possible ProgIds history with extension
New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\ApplicationAssociationToasts -Name "$($ProgID)_$($Extension)" -PropertyType DWord -Value 0 -Force
}
}
$Name = "{0}_$Extension" -f (Split-Path -Path $ProgId -Leaf)
New-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\ApplicationAssociationToasts" -Name $Name -PropertyType DWord -Value 0 -Force
$Name = "{0}_$($Extension)" -f (Split-Path -Path $ProgId -Leaf)
New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\ApplicationAssociationToasts -Name $Name -PropertyType DWord -Value 0 -Force
if ("$ProgId_$Extension" -ne $Name)
if ("$($ProgID)_$($Extension)" -ne $Name)
{
New-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\ApplicationAssociationToasts" -Name "$ProgId_$Extension" -PropertyType DWord -Value 0 -Force
New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\ApplicationAssociationToasts -Name "$($ProgID)_$($Extension)" -PropertyType DWord -Value 0 -Force
}
# If ProgId doesn't exist set the specified ProgId for the extensions
if (-not $OrigProgID)
# Due to "Set-StrictMode -Version Latest" we have to check everything
if (-not (Get-Variable -Name OrigProgID -ErrorAction Ignore))
{
if (-not (Test-Path -Path "HKCU:\Software\Classes\$Extension"))
{
@ -8322,7 +8335,8 @@ namespace RegistryUtils
New-ItemProperty -Path "HKCU:\Software\Classes\$Extension\OpenWithProgids" -Name $ProgId -PropertyType None -Value ([byte[]]@()) -Force
# Set the system ProgId to the extension parameters for the File Explorer to the possible options for the assignment, and if absent set the specified ProgId
if ($OrigProgID)
# Due to "Set-StrictMode -Version Latest" we have to check everything
if (Get-Variable -Name OrigProgID -ErrorAction Ignore)
{
if (-not (Test-Path -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\$Extension\OpenWithProgids"))
{
@ -8380,13 +8394,17 @@ namespace RegistryUtils
)
# If there is the system extension ProgId, write it to the already configured by default
if ((Get-ItemProperty -Path "HKLM:\SOFTWARE\Classes\$Extension" -Name "(default)" -ErrorAction Ignore)."(default)")
# Due to "Set-StrictMode -Version Latest" we have to check everything
if ((Test-Path -Path "HKLM:\SOFTWARE\Classes\$Extension") -and (Get-ItemProperty -Path "HKLM:\SOFTWARE\Classes\$Extension" -Name "(default)" -ErrorAction Ignore))
{
if (-not (Test-Path -Path Registry::HKEY_USERS\.DEFAULT\Software\Microsoft\Windows\CurrentVersion\FileAssociations\ProgIds))
if ((Get-ItemProperty -Path "HKLM:\SOFTWARE\Classes\$Extension" -Name "(default)" -ErrorAction Ignore)."(default)")
{
New-Item -Path Registry::HKEY_USERS\.DEFAULT\Software\Microsoft\Windows\CurrentVersion\FileAssociations\ProgIds -Force
if (-not (Test-Path -Path Registry::HKEY_USERS\.DEFAULT\Software\Microsoft\Windows\CurrentVersion\FileAssociations\ProgIds))
{
New-Item -Path Registry::HKEY_USERS\.DEFAULT\Software\Microsoft\Windows\CurrentVersion\FileAssociations\ProgIds -Force
}
New-ItemProperty -Path Registry::HKEY_USERS\.DEFAULT\Software\Microsoft\Windows\CurrentVersion\FileAssociations\ProgIds -Name "_$($Extension)" -PropertyType DWord -Value 1 -Force
}
New-ItemProperty -Path Registry::HKEY_USERS\.DEFAULT\Software\Microsoft\Windows\CurrentVersion\FileAssociations\ProgIds -Name "_$Extension" -PropertyType DWord -Value 1 -Force
}
# Setting 'NoOpenWith' for all registered the extension ProgIDs
@ -8414,12 +8432,24 @@ namespace RegistryUtils
}
}
$picture = (Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\KindMap" -Name $Extension -ErrorAction Ignore).$Extension
$PBrush = (Get-ItemProperty -Path "HKLM:\SOFTWARE\Classes\PBrush\CLSID" -Name "(default)" -ErrorAction Ignore)."(default)"
# Due to "Set-StrictMode -Version Latest" we have to check everything
if (Get-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\KindMap -Name $Extension -ErrorAction Ignore)
{
$picture = (Get-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\KindMap -Name $Extension -ErrorAction Ignore).$Extension
}
# Due to "Set-StrictMode -Version Latest" we have to check everything
if ((Test-Path -Path HKLM:\SOFTWARE\Classes\PBrush\CLSID) -and (Get-ItemProperty -Path HKLM:\SOFTWARE\Classes\PBrush\CLSID -Name "(default)" -ErrorAction Ignore))
{
$PBrush = (Get-ItemProperty -Path HKLM:\SOFTWARE\Classes\PBrush\CLSID -Name "(default)" -ErrorAction Ignore)."(default)"
}
if (($picture -eq "picture") -and $PBrush)
# Due to "Set-StrictMode -Version Latest" we have to check everything
if (Get-Variable -Name picture -ErrorAction Ignore)
{
New-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\ApplicationAssociationToasts" -Name "PBrush_$Extension" -PropertyType DWord -Value 0 -Force
if (($picture -eq "picture") -and $PBrush)
{
New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\ApplicationAssociationToasts -Name "PBrush_$($Extension)" -PropertyType DWord -Value 0 -Force
}
}
}

2
src/Sophia_Script_for_Windows_11/Sophia.ps1

@ -90,7 +90,7 @@ Import-LocalizedData -BindingVariable Global:Localization -BaseDirectory $PSScri
#>
if ($Functions)
{
#Invoke-Command -ScriptBlock {Checks}
Invoke-Command -ScriptBlock {Checks}
foreach ($Function in $Functions)
{

66
src/Sophia_Script_for_Windows_11_PowerShell_7/Module/Sophia.psm1

@ -7997,6 +7997,15 @@ function Set-Association
$ProgramPath = [System.Environment]::ExpandEnvironmentVariables($ProgramPath)
if (-not (Test-Path -Path $ProgramPath))
{
Write-Verbose -Message $Localization.Skipped -Verbose
Write-Error -Message $Localization.NoInternetConnection -ErrorAction SilentlyContinue
Write-Error -Message ($Localization.RestartFunction -f $MyInvocation.Line) -ErrorAction SilentlyContinue
return
}
if ($Icon)
{
$Icon = [System.Environment]::ExpandEnvironmentVariables($Icon)
@ -8292,23 +8301,27 @@ namespace RegistryUtils
$Extension
)
$OrigProgID = (Get-ItemProperty -Path "HKLM:\SOFTWARE\Classes\$Extension" -Name "(default)" -ErrorAction Ignore)."(default)"
if ($OrigProgID)
# Due to "Set-StrictMode -Version Latest" we have to check everything
if ((Test-Path -Path "HKLM:\SOFTWARE\Classes\$Extension") -and (Get-ItemProperty -Path "HKLM:\SOFTWARE\Classes\$Extension" -Name "(default)" -ErrorAction Ignore))
{
# Save possible ProgIds history with extension
New-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\ApplicationAssociationToasts" -Name "$ProgID_$Extension" -PropertyType DWord -Value 0 -Force
if ((Get-ItemProperty -Path "HKLM:\SOFTWARE\Classes\$Extension" -Name "(default)" -ErrorAction Ignore)."(default)")
{
# Save possible ProgIds history with extension
New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\ApplicationAssociationToasts -Name "$($ProgID)_$($Extension)" -PropertyType DWord -Value 0 -Force
}
}
$Name = "{0}_$Extension" -f (Split-Path -Path $ProgId -Leaf)
New-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\ApplicationAssociationToasts" -Name $Name -PropertyType DWord -Value 0 -Force
$Name = "{0}_$($Extension)" -f (Split-Path -Path $ProgId -Leaf)
New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\ApplicationAssociationToasts -Name $Name -PropertyType DWord -Value 0 -Force
if ("$ProgId_$Extension" -ne $Name)
if ("$($ProgID)_$($Extension)" -ne $Name)
{
New-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\ApplicationAssociationToasts" -Name "$ProgId_$Extension" -PropertyType DWord -Value 0 -Force
New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\ApplicationAssociationToasts -Name "$($ProgID)_$($Extension)" -PropertyType DWord -Value 0 -Force
}
# If ProgId doesn't exist set the specified ProgId for the extensions
if (-not $OrigProgID)
# Due to "Set-StrictMode -Version Latest" we have to check everything
if (-not (Get-Variable -Name OrigProgID -ErrorAction Ignore))
{
if (-not (Test-Path -Path "HKCU:\Software\Classes\$Extension"))
{
@ -8325,7 +8338,8 @@ namespace RegistryUtils
New-ItemProperty -Path "HKCU:\Software\Classes\$Extension\OpenWithProgids" -Name $ProgId -PropertyType None -Value ([byte[]]@()) -Force
# Set the system ProgId to the extension parameters for the File Explorer to the possible options for the assignment, and if absent set the specified ProgId
if ($OrigProgID)
# Due to "Set-StrictMode -Version Latest" we have to check everything
if (Get-Variable -Name OrigProgID -ErrorAction Ignore)
{
if (-not (Test-Path -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\$Extension\OpenWithProgids"))
{
@ -8383,13 +8397,17 @@ namespace RegistryUtils
)
# If there is the system extension ProgId, write it to the already configured by default
if ((Get-ItemProperty -Path "HKLM:\SOFTWARE\Classes\$Extension" -Name "(default)" -ErrorAction Ignore)."(default)")
# Due to "Set-StrictMode -Version Latest" we have to check everything
if ((Test-Path -Path "HKLM:\SOFTWARE\Classes\$Extension") -and (Get-ItemProperty -Path "HKLM:\SOFTWARE\Classes\$Extension" -Name "(default)" -ErrorAction Ignore))
{
if (-not (Test-Path -Path Registry::HKEY_USERS\.DEFAULT\Software\Microsoft\Windows\CurrentVersion\FileAssociations\ProgIds))
if ((Get-ItemProperty -Path "HKLM:\SOFTWARE\Classes\$Extension" -Name "(default)" -ErrorAction Ignore)."(default)")
{
New-Item -Path Registry::HKEY_USERS\.DEFAULT\Software\Microsoft\Windows\CurrentVersion\FileAssociations\ProgIds -Force
if (-not (Test-Path -Path Registry::HKEY_USERS\.DEFAULT\Software\Microsoft\Windows\CurrentVersion\FileAssociations\ProgIds))
{
New-Item -Path Registry::HKEY_USERS\.DEFAULT\Software\Microsoft\Windows\CurrentVersion\FileAssociations\ProgIds -Force
}
New-ItemProperty -Path Registry::HKEY_USERS\.DEFAULT\Software\Microsoft\Windows\CurrentVersion\FileAssociations\ProgIds -Name "_$($Extension)" -PropertyType DWord -Value 1 -Force
}
New-ItemProperty -Path Registry::HKEY_USERS\.DEFAULT\Software\Microsoft\Windows\CurrentVersion\FileAssociations\ProgIds -Name "_$Extension" -PropertyType DWord -Value 1 -Force
}
# Setting 'NoOpenWith' for all registered the extension ProgIDs
@ -8417,12 +8435,24 @@ namespace RegistryUtils
}
}
$picture = (Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\KindMap" -Name $Extension -ErrorAction Ignore).$Extension
$PBrush = (Get-ItemProperty -Path "HKLM:\SOFTWARE\Classes\PBrush\CLSID" -Name "(default)" -ErrorAction Ignore)."(default)"
# Due to "Set-StrictMode -Version Latest" we have to check everything
if (Get-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\KindMap -Name $Extension -ErrorAction Ignore)
{
$picture = (Get-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\KindMap -Name $Extension -ErrorAction Ignore).$Extension
}
# Due to "Set-StrictMode -Version Latest" we have to check everything
if ((Test-Path -Path HKLM:\SOFTWARE\Classes\PBrush\CLSID) -and (Get-ItemProperty -Path HKLM:\SOFTWARE\Classes\PBrush\CLSID -Name "(default)" -ErrorAction Ignore))
{
$PBrush = (Get-ItemProperty -Path HKLM:\SOFTWARE\Classes\PBrush\CLSID -Name "(default)" -ErrorAction Ignore)."(default)"
}
if (($picture -eq "picture") -and $PBrush)
# Due to "Set-StrictMode -Version Latest" we have to check everything
if (Get-Variable -Name picture -ErrorAction Ignore)
{
New-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\ApplicationAssociationToasts" -Name "PBrush_$Extension" -PropertyType DWord -Value 0 -Force
if (($picture -eq "picture") -and $PBrush)
{
New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\ApplicationAssociationToasts -Name "PBrush_$($Extension)" -PropertyType DWord -Value 0 -Force
}
}
}

Loading…
Cancel
Save