Repository navigation
Bug clean script not work key empty - #197
Conversation
👀 Heads Up — Manual Review RequiredHi @Magnetarman, However, the automated check detected that one or more sensitive WinToolkit files were modified, which affect the user interface, the main template or the project's static resources: Sensitive files modified
Why this notice?These files are not blocked for contributors, but they require additional verification by the maintainer before merging, because unexpected changes could:
Next stepsNo action is required from you. The maintainer will review the changes with extra care before merging. Automated notification from the WinToolkit CI/CD system — PR #197. |
👀 Heads Up — Manual Review RequiredHi @Magnetarman, However, the automated check detected that one or more sensitive WinToolkit files were modified, which affect the user interface, the main template or the project's static resources: Sensitive files modified
Why this notice?These files are not blocked for contributors, but they require additional verification by the maintainer before merging, because unexpected changes could:
Next stepsNo action is required from you. The maintainer will review the changes with extra care before merging. Automated notification from the WinToolkit CI/CD system — PR #197. |
👀 Heads Up — Manual Review RequiredHi @Magnetarman, However, the automated check detected that one or more sensitive WinToolkit files were modified, which affect the user interface, the main template or the project's static resources: Sensitive files modified
Why this notice?These files are not blocked for contributors, but they require additional verification by the maintainer before merging, because unexpected changes could:
Next stepsNo action is required from you. The maintainer will review the changes with extra care before merging. Automated notification from the WinToolkit CI/CD system — PR #197. |
👀 Heads Up — Manual Review RequiredHi @Magnetarman, However, the automated check detected that one or more sensitive WinToolkit files were modified, which affect the user interface, the main template or the project's static resources: Sensitive files modified
Why this notice?These files are not blocked for contributors, but they require additional verification by the maintainer before merging, because unexpected changes could:
Next stepsNo action is required from you. The maintainer will review the changes with extra care before merging. Automated notification from the WinToolkit CI/CD system — PR #197. |
Description
Running WinCleaner aborted at startup. Two sequential defects were identified from the
attached log and fixed:
Cannot bind argument to parameter 'Key' because it is an empty stringIl termine 'Get-LocalUserProfiles' non è riconosciuto come nome di un cmdlet...1. Empty
NameKeycrashesInvoke-CommandActionInvoke-CommandAction(intools/WinCleaner.ps1) resolved the display name with:Get-SourceTextLocdeclares[Parameter(Mandatory = $true)][string]$Key; PowerShell rejects anempty string with “Cannot bind argument to parameter 'Key' because it is an empty string”
(reproduced and confirmed).
Invoke-CommandActionis used to fire two inlinecleanmgr.exeCommandrules —cleanMgrExecutionRule(CleanMgr Config) and theWindows.oldremoval rule — and neitherdeclares a
NameKey. The first inlineCommandrule therefore passed an empty string toGet-SourceTextLocand threw at the very firstInvoke-CommandActioncall, aborting WinCleanerright after the Configurazione CleanMgr step.
Fix (
tools/WinCleaner.ps1):2.
Get-LocalUserProfilesis referenced but never definedAfter fix #1, WinCleaner progressed through CleanMgr, Error Reports, Event Logs and the
Windows Update cache, then aborted at Pulizia File Temporanei with
Il termine 'Get-LocalUserProfiles' non è riconosciuto.Get-LocalUserProfilesis called by five per-user rules intools/WinCleaner.ps1(
Remove-FileItem, plus the inlinecleanmgrcache / WinINET / Chromium / Firefox ScriptBlocks)but is not defined anywhere in the repository. It was treated as a core helper that was never
authored.
Fix (
tools/WinCleaner.ps1): defineGet-LocalUserProfilesas a private WinCleaner helperthat returns local user profile directories (objects with
.FullName, excluding system profiles)and delegates to the existing shared core helper
Get-SourceTextLocalUserProfiles(
wintoolkit-modules/40-Module.System.ps1) when available, with a self-contained fallback:This is the minimal, atomic fix:
Get-LocalUserProfilesis referenced only by WinCleaner(verified — no other tool/script defines or calls it), so a WinCleaner-private helper is correct.
Behaviour is delegated to the canonical shared helper (DRY), avoiding a second duplicate in core.
Bug fix.
Fixes # (no linked issue)
Type of Change
Files Modified
tools/WinCleaner.ps1Invoke-CommandAction: resolveDisplayNameonly whenNameKeyis present, else fall back to$Rule.Name(fixes crash V2.0 (Build 68) #1).Get-LocalUserProfileshelper delegating to the coreGet-SourceTextLocalUserProfileswith a fallback (fixes crash v2.0 (Build 69) #2).WinToolkit.ps1— regenerated bycompiler.ps1(not hand-edited; respects the repo policythat generated artifacts are never edited manually). The compiled core now contains
Get-LocalUserProfilesalongside theInvoke-CommandActionguard..github/tests/Unit/WinCleaner.Tests.ps1— added regression tests for both fixes:Tests & Verification
compiler.ps1(SUCCESS … code 0), not edited by handEnvironment: Windows 11 Pro 26H2 (build
26300), PowerShell 7.6.6.Checklist
WinToolkit.ps1not modified manually (regenerated bycompiler.ps1)WinToolkit.ps1) are not edited manuallyDev— branch isBUG-clean-script-not-work-key-empty; confirm intended base before mergetools/, a unit test under.github/tests/Unit/, and the compiler-regenerated artifact