Enhance Your Control: How to Hide Uninstall/Change/Repair Buttons in Windows Programs

Options
adrian
adrian Internal Posts: 3
edited December 2023 in Scripts

Are you tired of accidentally uninstalling or modifying critical programs? Want more control over what users can do with your installed applications? In this post, we'll explore a neat trick to hide the Uninstall/Change/Repair buttons from both the traditional "Add or Remove Programs" (appwiz.cpl) and the new "Apps & Features" modal in Windows. This simple tweak provides an extra layer of protection against unintentional modifications.

Benefits:

  • Reduce the risk of accidental uninstallations or modifications.
  • Enhance security by limiting user interactions with critical applications.
  • Customize the user experience by controlling how your installed programs appear in system settings.

How it Works: We'll use a PowerShell script to hide these buttons by modifying the registry entries associated with the installed application.

Before:

After:

Script:

$TargetString = 'Atera'
$RegistryPaths = @(
'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall',
'HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall'
)
foreach ($RegistryPath in $RegistryPaths) {
$InstallerKey = Get-InstallerKey -RegistryPath $RegistryPath -TargetString $TargetString
if ($InstallerKey) {
'NoRemove', 'NoRepair', 'NoModify' | ForEach-Object {
New-ItemProperty -Path $InstallerKey -Name $_ -Value '1' -PropertyType 'DWord'
}
}
}
function Get-InstallerKey {
param(
[string]$RegistryPath,
[string]$TargetString
)
Get-ChildItem $RegistryPath -Recurse -ErrorAction SilentlyContinue | ForEach-Object {
$CurrentKey = Get-ItemProperty -Path $_.PsPath
if ($CurrentKey -match $TargetString) {
return $CurrentKey.PSPath
}
}
}

Take charge of your installed programs and prevent accidental mishaps. Give it a try and let us know how it works for you! However, always remember to test scripts in a safe environment before deploying them system-wide. The effectiveness of scripts can vary based on system configurations, and unintended consequences may occur if not thoroughly tested.

Tagged:

Comments

  • tanderson
    tanderson Member Posts: 198 ✭✭✭✭
    Options

    @adrian It works well for other software as well!

  • tanderson
    tanderson Member Posts: 198 ✭✭✭✭
    Options

    @adrian Here is to turn it back so you can uninstall if needed!

    $TargetString = 'Atera'

    $RegistryPaths = @(
    'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall',
    'HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall'
    )

    foreach ($RegistryPath in $RegistryPaths) {
    $InstallerKey = Get-InstallerKey -RegistryPath $RegistryPath -TargetString $TargetString

    if ($InstallerKey) {
    'NoRemove', 'NoRepair', 'NoModify' | ForEach-Object {
    # Setting the value back to '0' to allow remove, repair, or modify options
    Set-ItemProperty -Path $InstallerKey -Name $_ -Value '0'
    }
    }

    }

    function Get-InstallerKey {
    param(
    [string]$RegistryPath,
    [string]$TargetString
    )

    Get-ChildItem $RegistryPath -Recurse -ErrorAction SilentlyContinue | ForEach-Object {
    $CurrentKey = Get-ItemProperty -Path $_.PsPath

    if ($CurrentKey -match $TargetString) {
    return $CurrentKey.PSPath
    }
    }

    }

  • adrian
    adrian Internal Posts: 3
    Options

    @tanderson indeed it works for other apps as well!

    Also, thanks for the revert script :D

  • nina
    nina Administrator Posts: 428 admin
    Options

    Thank you @adrian - this is super helpful!