From e0554aeece582b2ce36342923c7dd0222f2b2000 Mon Sep 17 00:00:00 2001 From: Christoph Date: Wed, 31 Jul 2024 14:09:03 +0200 Subject: [PATCH] Add additional Windows Explorer options --- Main.cs | 8 ++++++-- modifier/Optimizations.cs | 31 ++++++++++++++++++++++++++++++- 2 files changed, 36 insertions(+), 3 deletions(-) diff --git a/Main.cs b/Main.cs index fd121cb..bf08869 100644 --- a/Main.cs +++ b/Main.cs @@ -273,7 +273,9 @@ public record class Configuration( bool VMwareTools, bool VirtIoGuestTools, bool PreventDeviceEncryption, - bool ClassicContextMenu + bool ClassicContextMenu, + bool ShowFileExtensions, + HideModes HideFiles ) { public static Configuration Default => new( @@ -312,7 +314,9 @@ bool ClassicContextMenu VMwareTools: false, VirtIoGuestTools: false, PreventDeviceEncryption: false, - ClassicContextMenu: false + ClassicContextMenu: false, + ShowFileExtensions: false, + HideFiles: HideModes.Hidden ); } diff --git a/modifier/Optimizations.cs b/modifier/Optimizations.cs index 7b45d72..6236274 100644 --- a/modifier/Optimizations.cs +++ b/modifier/Optimizations.cs @@ -10,6 +10,11 @@ public record class EnabledProcessAuditSettings( bool IncludeCommandLine ) : IProcessAuditSettings; +public enum HideModes +{ + None, HiddenSystem, Hidden +} + public class DisabledProcessAuditSettings : IProcessAuditSettings; class OptimizationsModifier(ModifierContext context) : Modifier(context) @@ -18,6 +23,30 @@ public override void Process() { CommandAppender appender = GetAppender(CommandConfig.Specialize); + { + IEnumerable SetExplorerOptions(string rootKey, string subKey) + { + if (Configuration.ShowFileExtensions) + { + yield return CommandBuilder.RegistryCommand(@$"add ""{rootKey}\{subKey}\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced"" /v ""HideFileExt"" /t REG_DWORD /d 0 /f"); + } + + switch (Configuration.HideFiles) + { + case HideModes.None: + yield return CommandBuilder.RegistryCommand(@$"add ""{rootKey}\{subKey}\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced"" /v ""Hidden"" /t REG_DWORD /d 1 /f"); + yield return CommandBuilder.RegistryCommand(@$"add ""{rootKey}\{subKey}\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced"" /v ""ShowSuperHidden"" /t REG_DWORD /d 1 /f"); + break; + case HideModes.HiddenSystem: + yield return CommandBuilder.RegistryCommand(@$"add ""{rootKey}\{subKey}\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced"" /v ""Hidden"" /t REG_DWORD /d 1 /f"); + break; + case HideModes.Hidden: + break; + } + } + appender.Append(CommandBuilder.RegistryDefaultUserCommand(SetExplorerOptions)); + } + if (Configuration.DisableDefender) { if (Configuration.DisableDefenderPE) @@ -58,7 +87,7 @@ public override void Process() ); } - if(Configuration.DisableSac) + if (Configuration.DisableSac) { appender.Append( CommandBuilder.RegistryCommand(@"add ""HKLM\SYSTEM\CurrentControlSet\Control\CI\Policy"" /v VerifiedAndReputablePolicyState /t REG_DWORD /d 0 /f")