From 1fd479c1f75e2350972b725ad6ee692509dcad06 Mon Sep 17 00:00:00 2001 From: zoicware <118035521+zoicware@users.noreply.github.com> Date: Wed, 4 Feb 2026 00:43:41 -0500 Subject: [PATCH] disable app actions via settings.dat --- RemoveWindowsAi.ps1 | 118 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 117 insertions(+), 1 deletion(-) diff --git a/RemoveWindowsAi.ps1 b/RemoveWindowsAi.ps1 index 7870a40..61b6a5c 100644 --- a/RemoveWindowsAi.ps1 +++ b/RemoveWindowsAi.ps1 @@ -394,6 +394,95 @@ function Create-RestorePoint { } +function Set-UwpAppRegistryEntry { + # modified to work in windows powershell from https://github.com/agadiffe/WindowsMize/blob/fe78912ccb1c83d440bd2123f5e43a6156fab31a/src/modules/applications/settings/public/Set-UwpAppSetting.ps1 + <# + .SYNOPSIS + Modifies UWP app registry entries in the settings.dat file. + + .EXAMPLE + PS> $setting = [PSCustomObject]@{ + Name = 'VideoAutoplay' + Value = '0' + Type = '5f5e10b' + } + PS> $setting | Set-UwpAppRegistryEntry -FilePath $FilePath + #> + + [CmdletBinding()] + param + ( + [Parameter(Mandatory, ValueFromPipeline)] + $InputObject, + + [Parameter(Mandatory)] + [string] $FilePath + ) + + begin { + $AppSettingsRegPath = 'HKEY_USERS\APP_SETTINGS' + $RegContent = "Windows Registry Editor Version 5.00`n" + } + + process { + $Value = $InputObject.Value + $Value = switch ($InputObject.Type) { + '5f5e10b' { + # Single byte for boolean + '{0:x2}' -f [byte][int]$Value + } + '5f5e10c' { + # Unicode string + $bytes = [System.Text.Encoding]::Unicode.GetBytes($Value + "`0") + ($bytes | ForEach-Object { '{0:x2}' -f $_ }) -join ' ' + } + '5f5e104' { + # Int32 + $bytes = [BitConverter]::GetBytes([int]$Value) + ($bytes | ForEach-Object { '{0:x2}' -f $_ }) -join ' ' + } + '5f5e105' { + # UInt32 + $bytes = [BitConverter]::GetBytes([uint32]$Value) + ($bytes | ForEach-Object { '{0:x2}' -f $_ }) -join ' ' + } + '5f5e106' { + # Int64 + $bytes = [BitConverter]::GetBytes([int64]$Value) + ($bytes | ForEach-Object { '{0:x2}' -f $_ }) -join ' ' + } + } + + $Value = $Value -replace '\s+', ',' + + # create timestamp for remaining bytes + $timestampBytes = [BitConverter]::GetBytes([int64](Get-Date).ToFileTime()) + $Timestamp = ($timestampBytes | ForEach-Object { '{0:x2}' -f $_ }) -join ',' + + # build registry content + if ($InputObject.Path) { + $RegKey = $InputObject.Path + } + else { + $RegKey = 'LocalState' + } + $RegContent += "`n[$AppSettingsRegPath\$RegKey] + ""$($InputObject.Name)""=hex($($InputObject.Type)):$Value,$Timestamp`n" -replace '(?m)^ *' + } + + end { + $SettingRegFilePath = "$($tempDir)uwp_app_settings.reg" + $RegContent | Out-File -FilePath $SettingRegFilePath + + reg.exe UNLOAD $AppSettingsRegPath 2>&1 | Out-Null + reg.exe LOAD $AppSettingsRegPath $FilePath | Out-Null + reg.exe IMPORT $SettingRegFilePath 2>&1 | Out-Null + reg.exe UNLOAD $AppSettingsRegPath | Out-Null + + Remove-Item -Path $SettingRegFilePath + } +} + function Disable-Registry-Keys { #maybe add params for particular parts @@ -927,7 +1016,34 @@ Windows Registry Editor Version 5.00 Remove-Item "$($tempDir)DisableAIPhotos.reg" -Force -ErrorAction SilentlyContinue } - + #disable app actions + #method credit : https://github.com/agadiffe/WindowsMize + $settingsDat = "$env:LOCALAPPDATA\Packages\MicrosoftWindows.Client.CBS_cw5n1h2txyewy\Settings\settings.dat" + + if (Test-Path $settingsDat) { + Write-Status -msg "$(@('Disabling','Enabling')[$revert]) App Actions..." + + $apps = @( + 'Microsoft.MicrosoftOfficeHub_8wekyb3d8bbwe' + 'Microsoft.Office.ActionsServer_8wekyb3d8bbwe' + 'MSTeams_8wekyb3d8bbwe' + 'Microsoft.Paint_8wekyb3d8bbwe' + 'Microsoft.Windows.Photos_8wekyb3d8bbwe' + 'MicrosoftWindows.Client.CBS_cw5n1h2txyewy' #describe image (system) + ) + #prevent file lock + Stop-Process -Name @('SearchHost', 'AppActions') -Force -ErrorAction SilentlyContinue + foreach ($app in $apps) { + $setting = [PSCustomObject]@{ + Name = $app + Path = 'LocalState\DisabledApps' + Value = @('1', '0')[$revert] # 1 = disable 0 = enable + Type = '5f5e10b' + } + $setting | Set-UwpAppRegistryEntry -FilePath $settingsDat + } + + } #force policy changes