Skip to content

Commit

Permalink
Add setting to show all tray icons #34
Browse files Browse the repository at this point in the history
  • Loading branch information
cschneegans committed Aug 15, 2024
1 parent 9dfa0d4 commit 7fcc1a0
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 1 deletion.
14 changes: 13 additions & 1 deletion Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -151,13 +151,23 @@ public static string RegistryCommand(string value)
}

public static string UserRunOnceCommand(string rootKey, string subKey, string name, string command)
{
return UserRunCommand(rootKey, subKey, "RunOnce", name, command);
}

public static string RunAtLogonCommand(string rootKey, string subKey, string name, string command)
{
return UserRunCommand(rootKey, subKey, "Run", name, command);
}

private static string UserRunCommand(string rootKey, string subKey, string runKey, string name, string command)
{
static string Escape(string s)
{
return s.Replace(@"""", @"\""");
}

return RegistryCommand(@$"add ""{rootKey}\{subKey}\Software\Microsoft\Windows\CurrentVersion\Runonce"" /v ""{Escape(name)}"" /t REG_SZ /d ""{Escape(command)}"" /f");
return RegistryCommand(@$"add ""{rootKey}\{subKey}\Software\Microsoft\Windows\CurrentVersion\{runKey}"" /v ""{Escape(name)}"" /t REG_SZ /d ""{Escape(command)}"" /f");
}

public delegate IEnumerable<string> RegistryDefaultUserAction(string rootKey, string subKey);
Expand Down Expand Up @@ -287,6 +297,7 @@ public record class Configuration(
bool PreventDeviceEncryption,
bool ClassicContextMenu,
bool ShowFileExtensions,
bool ShowAllTrayIcons,
HideModes HideFiles
)
{
Expand Down Expand Up @@ -330,6 +341,7 @@ HideModes HideFiles
PreventDeviceEncryption: false,
ClassicContextMenu: false,
ShowFileExtensions: false,
ShowAllTrayIcons: false,
HideFiles: HideModes.Hidden
);
}
Expand Down
2 changes: 2 additions & 0 deletions UnattendGenerator.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<None Remove="resource\RemoveCapabilities.ps1" />
<None Remove="resource\RemoveFeatures.ps1" />
<None Remove="resource\RemovePackages.ps1" />
<None Remove="resource\ShowAllTrayIcons.ps1" />
</ItemGroup>

<ItemGroup>
Expand All @@ -25,6 +26,7 @@
<EmbeddedResource Include="resource\KeyboardIdentifier.json" />
<EmbeddedResource Include="resource\Bloatware.json" />
<EmbeddedResource Include="resource\known-writeable-folders.txt" />
<EmbeddedResource Include="resource\ShowAllTrayIcons.ps1" />
<EmbeddedResource Include="resource\RemoveBloatware.ps1" />
<EmbeddedResource Include="resource\TimeOffset.json" />
<EmbeddedResource Include="resource\TurnOffSystemSounds.ps1" />
Expand Down
17 changes: 17 additions & 0 deletions modifier/Optimizations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,23 @@ IEnumerable<string> SetExplorerOptions(string rootKey, string subKey)
appender.Append(CommandBuilder.RegistryDefaultUserCommand(SetExplorerOptions));
}

if (Configuration.ShowAllTrayIcons)
{
string ps1File = @"C:\Windows\Setup\Scripts\ShowAllTrayIcons.ps1";
string script = Util.StringFromResource("ShowAllTrayIcons.ps1");
AddTextFile(script, ps1File);

appender.Append(
CommandBuilder.RegistryDefaultUserCommand((rootKey, subKey) =>
{
return [
CommandBuilder.RegistryCommand(@$"add ""{rootKey}\{subKey}\Software\Microsoft\Windows\CurrentVersion\Explorer"" /v EnableAutoTray /t REG_DWORD /d 0 /f"),
CommandBuilder.RunAtLogonCommand(rootKey, subKey, "ShowAllTrayIcons", CommandBuilder.InvokePowerShellScript(ps1File)),
];
})
);
}

if (Configuration.DisableDefender)
{
if (Configuration.DisableDefenderPE)
Expand Down
4 changes: 4 additions & 0 deletions resource/ShowAllTrayIcons.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Set-Location -LiteralPath 'HKCU:\';
Get-Item -Path 'HKCU:\Control Panel\NotifyIconSettings\*' -ErrorAction 'SilentlyContinue' | ForEach-Object -Process {
$_ | Set-ItemProperty -Name 'IsPromoted' -Value 1 -Type 'DWord';
};

0 comments on commit 7fcc1a0

Please sign in to comment.