windows-clean-files 1.0.2

dotnet tool install --global windows-clean-files --version 1.0.2
                    
This package contains a .NET tool you can call from the shell/command line.
dotnet new tool-manifest
                    
if you are setting up this repo
dotnet tool install --local windows-clean-files --version 1.0.2
                    
This package contains a .NET tool you can call from the shell/command line.
#tool dotnet:?package=windows-clean-files&version=1.0.2
                    
nuke :add-package windows-clean-files --version 1.0.2
                    

windows-clean-files

A console UI tool (using RazorConsole) to audit and safely clean up orphaned MSI/MSP cache files ("arquivos órfãos") from C:\\Windows\\Installer on Windows.

This is a C# rewrite of the original PowerShell script arquivos.ps1, with a richer TUI dashboard instead of command-line switches.

What it does

  • Scans C:\\Windows\\Installer for .msi and .msp files.
  • Uses the Windows registry to detect which MSI/MSP files are still referenced by installed products.
  • Marks files as:
    • Orphaned ("arquivos órfãos"): present on disk but not referenced in the registry.
    • In use: currently locked by another process.
    • Safe to remove: orphaned and not in use.
  • Produces an audit report:
    • C:\\Temp\\Installer_Audit_<timestamp>.csv summarizing all files and flags.
    • C:\\Temp\\Installer_Cleanup_<timestamp>.log with a log of the run.
  • Optionally moves safe-to-remove files into a backup folder instead of deleting them:
    • C:\\Temp\\InstallerBackup_<timestamp>\\ with all moved files.
    • manifest.csv inside the backup with the full list of moved files.
  • Shows a PowerShell command you can use later to restore those files to C:\\Windows\\Installer if needed.

Safety model

This tool is designed to be conservative and reversible:

  • It only considers .msi and .msp files under C:\\Windows\\Installer.
  • It checks the Windows registry for references before considering a file orphaned.
  • It checks whether a file is locked/in use before marking it safe.
  • It never deletes files directly:
    • It moves safe files to a timestamped backup directory.
    • It writes a CSV manifest for rollback.
  • It mimics the logic of the original arquivos.ps1 script, but runs as a console UI.

Requirements

  • Windows (registry scanning is Windows-only and the paths are Windows-specific).
  • .NET 10.0 SDK (as configured in windows-clean-files.csproj).
  • Run the tool in a console that supports ANSI colors for the best experience.

Note: For best results, run the tool from an elevated (Administrator) PowerShell session, as cleaning C:\\Windows\\Installer may require admin rights.

How to build and run

From the windows-clean-files project folder:

cd C:\dev\cli-dead-files\windows-clean-files\windows-clean-files

# Build
dotnet build

# Run (launches the RazorConsole UI)
dotnet run

When the app starts, you'll see a text-based dashboard called "Windows Installer Cleanup".

Using the UI

The main screen shows:

  • A title banner.
  • A configuration panel showing:
    • Caminho da pasta Installer: C:\\Windows\\Installer
    • Pasta de saída: C:\\Temp
  • Buttons:
    • Executar auditoria
    • Remover órfãos (com confirmação)
    • Sair

Step 1: Audit

  1. Use the keyboard to focus the "Executar auditoria" button and press Enter.
  2. The tool will:
    • Scan C:\\Windows\\Installer for .msi/.msp files.
    • Query the registry for referenced MSI/MSP paths.
    • Test potential orphan files to see if they are currently in use.
    • Write:
      • Installer_Audit_<timestamp>.csv in C:\\Temp.
      • Installer_Cleanup_<timestamp>.log in C:\\Temp.
  3. A Resumo panel appears showing:
    • Espaço total ocupado – total disk space used by all MSI/MSP files.
    • Arquivos órfãos identificados – count of orphaned files.
    • Espaço órfão – total size of orphaned files.
    • Arquivos seguros para remover – how many files are considered safe to move.
    • Espaço recuperável – how much disk space you can reclaim.
    • Relatório – the path to the CSV report.

Step 2: Clean up orphaned files (optional)

After running the audit:

  1. If there are files marked safe to remove, focus "Remover órfãos (com confirmação)" and press Enter.
  2. A Confirmação panel is shown with:
    • How many files will be moved.
    • How much space will be freed.
    • The backup folder path (e.g. C:\\Temp\\InstallerBackup_20250101_120000).
  3. Choose:
    • "Confirmar" to proceed, or
    • "Cancelar" to go back.
  4. On confirmation, the tool will:
    • Create the backup folder under C:\\Temp.
    • Write manifest.csv inside that folder.
    • Move each safe file from C:\\Windows\\Installer into the backup.
    • Log the results (success/fail counts, space freed) to the log file.

Rolling back (restoring moved files)

If you decide to restore the moved MSI/MSP files later:

  1. Locate the backup folder path displayed in the UI (and in the log), e.g.:

    C:\Temp\InstallerBackup_20250101_120000
    
  2. From an elevated PowerShell session, run:

    Get-ChildItem 'C:\Temp\InstallerBackup_20250101_120000\*.msi*' | \
        Move-Item -Destination 'C:\Windows\Installer' -Force
    

This is the same restore command that the original arquivos.ps1 script printed.

Relationship to arquivos.ps1

  • arquivos.ps1 is kept in the repository for reference.
  • The C# app reimplements the same core behavior:
    • Registry-based detection of referenced MSI/MSP files.
    • Orphan/in-use/safe classification.
    • CSV/export and logging.
    • Backup + manifest + restore command.
  • The main differences:
    • UI: text-based RazorConsole UI instead of CLI switches.
    • Execution: run via dotnet run or the built windows-clean-files.exe instead of calling arquivos.ps1.

If you already used arquivos.ps1 to remove "arquivos órfãos" (dead MSI cache files), you can now use this tool as a drop‑in replacement with a friendlier interface and the same safety guarantees.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

Version Downloads Last Updated
1.0.2 227 12/5/2025