Skip to content

fix(tweaks): Correct operator for checking tweak type in Invoke-WinUt…#3625

Merged
ChrisTitusTech merged 1 commit intoChrisTitusTech:mainfrom
ZeusCraft10:patch-2
Nov 17, 2025
Merged

fix(tweaks): Correct operator for checking tweak type in Invoke-WinUt…#3625
ChrisTitusTech merged 1 commit intoChrisTitusTech:mainfrom
ZeusCraft10:patch-2

Conversation

@ZeusCraft10
Copy link
Contributor

Type of Change

  • New feature
  • Bug fix
  • Documentation update
  • Refactoring
  • Hotfix
  • Security patch
  • UI/UX improvement

Description

This pull request resolves a bug in the tweak execution logic within the Invoke-WinUtilTweaks function. Previously, the script used the -contains operator to check if a tweak was a "Toggle" type. This is incorrect, as -contains is designed for arrays, not for finding a substring within a string.

This logical error caused the script to sometimes execute the actions of an incorrect tweak. For example, selecting the "Set Classic Right-Click Menu" tweak would result in the script applying registry changes for the "Cross-Device Resume" tweak instead of the intended script.

The fix replaces the incorrect operator with -like "*Toggle*" to properly identify toggle-type tweaks by name, ensuring that the correct actions are performed for the user's selected tweaks.

Testing

  1. Applied the code change to functions/private/Invoke-WinUtilTweaks.ps1.
  2. Compiled the project using Compile.ps1.
  3. Launched the newly compiled winutil.ps1 as an administrator.
  4. Navigated to the "Tweaks" tab.
  5. Selected only the "Set Classic Right-Click Menu" tweak.
  6. Clicked "Run Tweaks".
  7. Verification:
    • Confirmed that the PowerShell output only contained actions related to the right-click menu tweak (creating the InprocServer32 key and restarting explorer.exe).
    • Verified that no unrelated output (e.g., concerning CrossDeviceResume) was displayed.
    • Confirmed that the classic right-click menu was successfully enabled in Windows Explorer.
    • Ran the "Undo Selected Tweaks" and confirmed it correctly ran the UndoScript for the right-click menu tweak.

Impact

This fix corrects a critical logic error, making the tweak application process reliable and preventing unintended and potentially confusing system changes. There are no new dependencies or negative performance impacts.

Issue related to PR

Additional Information

This change ensures the stability and predictability of the "Tweaks" feature.

Checklist

  • My code adheres to the coding and style guidelines of the project.
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have made corresponding changes to the documentation.
  • My changes generate no errors/warnings/merge conflicts.

…ilTweaks

The Invoke-WinUtilTweaks function was using the '-contains' operator on a string variable to check for toggle-type tweaks. This operator is intended for collections (arrays), not for substring matching within a string, leading to incorrect logic flow.

This caused an issue where selecting one tweak (e.g., WPFTweaksRightClickMenu) could erroneously trigger the action of another (e.g., WPFTweaksDisableCrossDeviceResume).

This commit replaces the incorrect '-contains' operator with the '-like' operator and appropriate wildcards ('*Toggle*'). This ensures that tweak types are identified correctly, resolving the bug and preventing unintended system modifications.
@ZeusCraft10
Copy link
Contributor Author

Sorry for Spamming PR's but I have ADHD, and I just downed 6 Red bulls. Im ready to make this whole project bug free.

)

if ($Checkbox -contains "Toggle") {
if ($Checkbox -like "*Toggle*") {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both should do the same thing. Correct me if I'm wrong, but don't use AI to correct me...

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

He is actually right on this. contains are for collections/arrays
like is a wildcard match for strings and isn't case sensitive as well.

@ChrisTitusTech ChrisTitusTech merged commit eeb410e into ChrisTitusTech:main Nov 17, 2025
1 check passed
This was referenced Nov 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

"Set Classic Right-Click Menu" does not work; difference from documentation?

3 participants