Skip to content

Free, open-source Windows optimization tool for performance, privacy, and simplicity.

fix: ShellFeedsTaskbarViewMode can now set normally (required to restart explorer) and add ":" trim for PS registry path

fatDuck0ea81ed0e838
diff --git a/optimizerDuck/Domain/Optimizations/Categories/SecurityAndPrivacy.cs b/optimizerDuck/Domain/Optimizations/Categories/SecurityAndPrivacy.cs
index 9f36144..baebccd 100644
--- a/optimizerDuck/Domain/Optimizations/Categories/SecurityAndPrivacy.cs
+++ b/optimizerDuck/Domain/Optimizations/Categories/SecurityAndPrivacy.cs
@@ -227,11 +227,13 @@ public class SecurityAndPrivacy : IOptimizationCategory
)]
public class DisableAdvertisingAndSuggestions : BaseOptimization
{
- public override Task<ApplyResult> ApplyAsync(
+ public override async Task<ApplyResult> ApplyAsync(
IProgress<ProcessingProgress> progress,
OptimizationContext context
)
{
+
+ // @formatter:off
RegistryService.Write(
new RegistryItem(
@"HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\AdvertisingInfo",
@@ -268,11 +270,6 @@ public class SecurityAndPrivacy : IOptimizationCategory
"DisableThirdPartySuggestions",
1
),
- new RegistryItem(
- @"HKCU\Software\Microsoft\Windows\CurrentVersion\Feeds",
- "ShellFeedsTaskbarViewMode",
- 2
- ),
new RegistryItem(
@"HKLM\SOFTWARE\Policies\Microsoft\Dsh",
"AllowNewsAndInterests",
@@ -319,11 +316,39 @@ public class SecurityAndPrivacy : IOptimizationCategory
0
)
);
-
+ // @formatter:on
context.Logger.LogInformation(
"Disabled advertising ID, consumer features and system suggestions"
);
- return Task.FromResult(CompleteFromScope());
+
+ // ShellFeedsTaskbarViewMode cannot be set while explorer.exe is running
+ // it should work....
+ var feedsPath = @"HKCU:\Software\Microsoft\Windows\CurrentVersion\Feeds";
+ var feedsItem = new RegistryItem(
+ @"HKCU\Software\Microsoft\Windows\CurrentVersion\Feeds",
+ "ShellFeedsTaskbarViewMode"
+ );
+
+ // null means the value never existed
+ var currentShellFeedsValue = RegistryService.Read<int?>(feedsItem);
+
+ var restartExplorer =
+ "Stop-Process -Name explorer -Force -ErrorAction SilentlyContinue; " + // just restart the explorer
+ "Start-Sleep -Milliseconds 1500; ";
+
+ var applyCmd =
+ $"{restartExplorer}" +
+ $"Set-ItemProperty -Path '{feedsPath}' -Name 'ShellFeedsTaskbarViewMode' -Value 2 -Type DWord;";
+
+ var revertCmd = currentShellFeedsValue.HasValue
+ ? $"{restartExplorer}" +
+ $"Set-ItemProperty -Path '{feedsPath}' -Name 'ShellFeedsTaskbarViewMode' -Value {currentShellFeedsValue.Value} -Type DWord;"
+ : $"{restartExplorer}" +
+ $"Remove-ItemProperty -Path '{feedsPath}' -Name 'ShellFeedsTaskbarViewMode' -ErrorAction SilentlyContinue;";
+
+ await ShellService.PowerShellAsync(applyCmd, revertCmd);
+
+ return CompleteFromScope();
}
}
diff --git a/optimizerDuck/Services/System/RegistryWatcher.cs b/optimizerDuck/Services/System/RegistryWatcher.cs
index 866904c..7994fd3 100644
--- a/optimizerDuck/Services/System/RegistryWatcher.cs
+++ b/optimizerDuck/Services/System/RegistryWatcher.cs
@@ -229,6 +229,10 @@ internal sealed class RegistryWatcher(ILogger<RegistryWatcher> logger) : IRegist
? path[..firstBackslash].ToUpperInvariant()
: path.ToUpperInvariant();
+ // Strip trailing colon for compatibility with RegistryService format (e.g. "HKLM:", "HKCU:")
+ if (root.EndsWith(":"))
+ root = root[..^1];
+
var subKey = firstBackslash > 0 ? path[(firstBackslash + 1)..] : string.Empty;
var hive = root switch