Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ jobs:
build-and-test:
runs-on: windows-2022
steps:
- uses: actions/checkout@v4
- uses: actions/setup-dotnet@v4
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
- uses: actions/setup-dotnet@67a3573c9a986a3f9c594539f4ab511d57bb3ce9 # v4
with:
dotnet-version: 10.0.x
- run: dotnet restore TweakHub.sln
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4

- name: Setup .NET
uses: actions/setup-dotnet@v4
uses: actions/setup-dotnet@67a3573c9a986a3f9c594539f4ab511d57bb3ce9 # v4
with:
dotnet-version: ${{ env.DOTNET_VERSION }}

Expand Down
6 changes: 5 additions & 1 deletion App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ public partial class App : Application
/// <summary>Playbook to run once the elevated restart has opened the main window.</summary>
public static string? StartupPlaybookId { get; set; }

/// <summary>Fingerprint of the playbook the user confirmed before the restart; a different one is confirmed again.</summary>
public static string? StartupPlaybookFingerprint { get; set; }

/// <summary>Starts TweakHub again as administrator and closes this instance; false when UAC is declined.</summary>
public static bool RestartElevated(string arguments)
{
Expand All @@ -34,7 +37,8 @@ public static bool RestartElevated(string arguments)
protected override void OnStartup(StartupEventArgs e)
{
L.Initialize(UserDataService.Instance.LoadAppearance().Language);
if (e.Args is ["--run-playbook", var playbookId]) StartupPlaybookId = playbookId;
if (e.Args is ["--run-playbook", var playbookId, var fingerprint])
(StartupPlaybookId, StartupPlaybookFingerprint) = (playbookId, fingerprint);
try { AppDataPath.EnsureAppsDirectory(); } catch { }

if (Environment.OSVersion.Version.Build < 22000)
Expand Down
7 changes: 6 additions & 1 deletion AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
using System.Runtime.CompilerServices;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Windows;

[assembly: InternalsVisibleTo("TweakHub.Tests")]

// Every P/Invoke target is a Windows (or AMD driver) DLL in System32: never load a same-named DLL dropped beside a
// portable TweakHub.exe, which would then run with the administrator rights TweakHub restarts with.
[assembly: DefaultDllImportSearchPaths(DllImportSearchPath.System32)]

[assembly:ThemeInfo(
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
//(used if a resource is not found in the page,
Expand Down
28 changes: 27 additions & 1 deletion MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,28 @@
TextOptions.TextFormattingMode="Display"
Background="{DynamicResource WindowBackgroundBrush}">

<ui:NavigationView x:Name="Navigation"
<!-- The title is drawn by TweakHub (the system caption cannot show italics); Windows still draws the caption buttons,
so snap layouts, the system menu and dark mode keep working. -->
<WindowChrome.WindowChrome>
<WindowChrome CaptionHeight="32" GlassFrameThickness="-1" UseAeroCaptionButtons="True"
ResizeBorderThickness="{x:Static SystemParameters.WindowResizeBorderThickness}"/>
</WindowChrome.WindowChrome>

<Grid x:Name="RootGrid">
<Grid.RowDefinitions>
<RowDefinition Height="32"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<StackPanel Orientation="Horizontal" VerticalAlignment="Center" Margin="12,0,0,0" Background="Transparent">
<Image Source="ico.ico" Width="16" Height="16" Margin="0,0,10,0" VerticalAlignment="Center"/>
<TextBlock FontSize="12" VerticalAlignment="Center" Foreground="{DynamicResource SystemControlForegroundBaseHighBrush}"
AutomationProperties.Name="{Binding Title, RelativeSource={RelativeSource AncestorType=Window}}">
<Run Text="TweakHub"/>
<Run Text="by Prime Build" FontStyle="Italic" Foreground="{DynamicResource SystemControlForegroundBaseMediumBrush}"/>
</TextBlock>
</StackPanel>

<ui:NavigationView x:Name="Navigation" Grid.Row="1"
PaneDisplayMode="Left"
IsPaneOpen="True"
IsPaneToggleButtonVisible="False"
Expand Down Expand Up @@ -67,6 +88,10 @@
AutomationProperties.Name="{loc:Loc Tools:SecurityTitle}">
<ui:NavigationViewItem.Icon><ui:FontIcon Glyph="&#xE72E;"/></ui:NavigationViewItem.Icon>
</ui:NavigationViewItem>
<ui:NavigationViewItem x:Name="StartupItem" Content="{loc:Loc Security:StartupPageTitle}" Tag="startup"
AutomationProperties.Name="{loc:Loc Security:StartupPageTitle}">
<ui:NavigationViewItem.Icon><ui:FontIcon Glyph="&#xE7B5;"/></ui:NavigationViewItem.Icon>
</ui:NavigationViewItem>
<ui:NavigationViewItem x:Name="DevicesItem" Content="{loc:Loc Devices:Title}" Tag="devices"
AutomationProperties.Name="{loc:Loc Devices:Title}">
<ui:NavigationViewItem.Icon><ui:FontIcon Glyph="&#xE772;"/></ui:NavigationViewItem.Icon>
Expand Down Expand Up @@ -118,4 +143,5 @@

<Frame x:Name="MainFrame" NavigationUIVisibility="Hidden" Background="Transparent"/>
</ui:NavigationView>
</Grid>
</Window>
15 changes: 15 additions & 0 deletions MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ public MainWindow()
// Cached pages need no journal: drop it so visited pages are not held twice.
MainFrame.Navigated += (_, _) => { while (MainFrame.CanGoBack) MainFrame.RemoveBackEntry(); };
ContentRendered += MainWindow_ContentRendered;
// With a custom chrome a maximized window overhangs the screen by its frame: pad it back in.
// shortcut: frame metrics come from the primary monitor (verified on two same-DPI monitors); compute per monitor if a mixed-DPI setup overhangs.
StateChanged += (_, _) => RootGrid.Margin = WindowState == WindowState.Maximized
? new Thickness(SystemParameters.WindowNonClientFrameThickness.Left, SystemParameters.WindowNonClientFrameThickness.Left,
SystemParameters.WindowNonClientFrameThickness.Right, SystemParameters.WindowNonClientFrameThickness.Bottom)
: new Thickness(0);
}

private void MainWindow_Loaded(object sender, RoutedEventArgs e)
Expand Down Expand Up @@ -53,6 +59,7 @@ private void Navigate(string destination)
{
"tools" => new ExternalToolsPage(),
"security" => new SecurityPage(),
"startup" => new StartupPage(),
"devices" => new DevicesPage(),
"power" => new PowerPlanPage(),
"scripts" => new AutomatedScriptsPage(),
Expand All @@ -65,6 +72,14 @@ private void Navigate(string destination)
if (destination == "registry") UpdateRegistryTweaksBadge();
}

/// <summary>Selects a section from inside another one, e.g. Security → System opening Startup.</summary>
public System.Windows.Controls.Page ShowSection(string destination)
{
Navigation.SelectedItem = Navigation.MenuItems.OfType<NavigationViewItem>().First(item => (string)item.Tag == destination);
Navigate(destination);
return _pages[destination];
}

/// <summary>After a profile import every other section must re-read its lists.</summary>
public void ResetPages()
{
Expand Down
19 changes: 18 additions & 1 deletion Models/Playbook.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,13 @@ public enum PlaybookStepType
Script,
Device,
Registry,
PowerPlan
PowerPlan,
// Appended: the type is stored as a number in playbooks.json and exported packages.
TweakCheck,
SecurityFix,
WindowsUpdate,
Service,
Dns
}

public sealed class Playbook
Expand Down Expand Up @@ -42,6 +48,11 @@ public sealed class PlaybookStep
PlaybookStepType.Script => "",
PlaybookStepType.Device => "",
PlaybookStepType.Registry => "",
PlaybookStepType.TweakCheck => "",
PlaybookStepType.SecurityFix => "",
PlaybookStepType.WindowsUpdate => "",
PlaybookStepType.Service => "",
PlaybookStepType.Dns => "",
_ => ""
};

Expand All @@ -53,6 +64,12 @@ public sealed class PlaybookStep
PlaybookStepType.Device => L.Format(TargetEnabled ? "Scripts:PlaybookEnableDevice" : "Scripts:PlaybookDisableDevice", Name),
PlaybookStepType.Registry => L.Format("Scripts:PlaybookRegistrySummary", Name),
PlaybookStepType.PowerPlan => L.Format("Scripts:PlaybookPowerSummary", Name),
PlaybookStepType.TweakCheck => L.Format("Scripts:PlaybookTweakCheckSummary", Name),
PlaybookStepType.SecurityFix => L.Format("Scripts:PlaybookSecurityFixSummary", Name),
PlaybookStepType.WindowsUpdate => L.Format("Scripts:PlaybookWindowsUpdateSummary", Name),
PlaybookStepType.Service => L.Format("Scripts:PlaybookServiceSummary", Name,
L.Get(Data == "4" ? "Maintenance:Disabled" : "Maintenance:Manual")),
PlaybookStepType.Dns => L.Format("Scripts:PlaybookDnsSummary", Name, Data),
_ => Name
};
}
Expand Down
15 changes: 15 additions & 0 deletions Models/TweakCategory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,15 @@ public bool IsRestartPending
public object? EnabledValue { get; set; }
public int RiskLevel { get; set; } = 1; // 1-5 scale

// Tweaks that only change how Windows looks or behaves visually.
private static readonly HashSet<string> CosmeticIds =
["disable_animations", "disable_transparency", "optimize_visual_effects", "reduce_menu_delay", "enable_taskbar_end_task", "detailed_bsod"];

/// <summary>Badge shown on the card: Safe (risk 1-2), Cosmetic, Moderate (3) or Caution (4-5).</summary>
public string RiskClass => CosmeticIds.Contains(Id) ? "Cosmetic" : RiskLevel <= 2 ? "Safe" : RiskLevel == 3 ? "Moderate" : "Caution";
public string RiskText => TweakHub.Localization.L.Get($"Tweaks:Risk{RiskClass}");
public string RiskHint => TweakHub.Localization.L.Get($"Tweaks:Risk{RiskClass}Hint");

/// <summary>Why this PC cannot use the tweak; empty when it can.</summary>
public string UnavailableReason
{
Expand Down Expand Up @@ -144,6 +153,12 @@ public class CustomRegistryTweak : System.ComponentModel.INotifyPropertyChanged
public string RegistryKey { get; set; } = string.Empty;
public string ValueType { get; set; } = "REG_SZ"; // REG_DWORD, REG_QWORD, REG_SZ
public string Data { get; set; } = string.Empty;
/// <summary>Badge the user picked: Safe, Cosmetic, Moderate or Caution. Moderate when unknown (older files).</summary>
public string RiskClass { get; set; } = "Moderate";
[System.Text.Json.Serialization.JsonIgnore]
public string RiskText => TweakHub.Localization.L.Get($"Tweaks:Risk{RiskClass}");
[System.Text.Json.Serialization.JsonIgnore]
public string RiskHint => TweakHub.Localization.L.Get($"Tweaks:Risk{RiskClass}Hint");
[System.Text.Json.Serialization.JsonIgnore]
public bool IsApplied
{
Expand Down
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@

TweakHub is built to live on a USB drive. Extract it once, add your preferred tools, scripts, Registry tweaks, favorites and appearance settings, then carry the complete folder between PCs. Your portable configuration stays with the app instead of being scattered across every machine you maintain.

It runs as the current user and requests administrator privileges only when an operation requires them. Every change is previewed first, backed up, and can be undone.
It runs as the current user and requests administrator privileges only when an operation requires them. Supported tweaks provide previews, backups and restoration. External tools and destructive maintenance scripts can make changes that TweakHub cannot undo.

## Features

Expand Down Expand Up @@ -107,6 +107,14 @@ It runs as the current user and requests administrator privileges only when an o
</tr>
</table>

New in 1.6.0:
- **Startup:** an Autoruns-style view of everything that starts with Windows (Run keys, startup folders, scheduled tasks, services, drivers, Explorer extensions, Winlogon, IFEO, WMI) with signatures and missing-file badges. Entries can be disabled or deleted with a backup and restored later; Windows-critical entries are protected.
- **Registry tweaks:** Group Policy power settings that stop automatic sleep, hibernation, disk spin-down and Energy Saver when plugged in, plus an optional tweak that turns sleep off completely. Also optional global Power Throttling control and hibernation management through `powercfg`. Risk badges and a risk filter on every tweak.
- **Devices:** "Disable unused" finds devices this PC does not use (for example the kernel debug adapter, or VPN miniports when no VPN is set up for any user) and disables the ones you tick in one step. A new **Drivers** tab removes old driver versions that a newer version replaces and no device uses, like Driver Store Explorer's "Select old drivers", with a backup of every package and one-click restore. **Affinity** places PCI interrupts on chosen logical CPUs, labelled by physical core and SMT thread.
- **Security:** optional services with individual startup-mode changes and restoration, a Policies tab that lists policies forced by other tools and resets them with a backup, and **Tron** with separate confirmed download, extraction and launch. Tron runs from a folder only administrators can change, after its SHA-256 is checked against the publisher's list. It can make irreversible changes: back up your files first. Microsoft Defender may block the Tron package; TweakHub never adds antivirus exclusions.

Portable does not mean system changes disappear when the app closes: keep the copy's `Data` directory to retain restoration data.

TweakHub supports **Windows 11 build 22000 or newer**.

<a id="languages"></a>The interface and installer support English, Russian, Simplified Chinese, Spanish, Italian and Japanese. TweakHub follows the Windows display language by default; an explicit language can be selected under **Settings**.
Expand Down Expand Up @@ -262,6 +270,10 @@ The device-metadata and Windows Update driver policies affect different content:

</details>

## Hardware reports

To help improve device detection and motherboard support, run the standalone [`Collect-TweakHub-Hardware.cmd`](Scripts/Collect-TweakHub-Hardware.cmd). It creates a local JSON report on the Desktop after consent, without changing settings or uploading anything. TweakHub and ThreadPilot do not need to be installed or running. See [collection instructions, privacy, limitations and Discord message](docs/hardware-reports.md) before sharing a report.

## Build from source

Requirements: Windows 11 and the .NET 10 SDK.
Expand Down
Loading
Loading