Skip to content

helloanaroul/clean-temp-files

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Clean Temp Files

A lightweight, open-source Windows desktop utility built with Electron and Node.js that automatically cleans temporary files from your system. Designed for simplicity, speed, and reliability — no GUI window, no unnecessary overhead. The application runs a batch script silently through a terminal window and exits immediately after completion.


Table of Contents


Overview

Clean Temp Files is a minimal Windows desktop application that targets and removes junk from two key system directories:

  • %TEMP% — the current user's temporary files folder
  • C:\Windows\Temp — the system-wide Windows temporary files folder

These directories accumulate cache, logs, install artifacts, and other disposable files over time, consuming significant disk space. This tool provides a one-click solution to reclaim that space safely, ignoring any files that are currently locked or in use by the operating system.


Features

  • Cleans user-level temp directory (%TEMP%) including all subdirectories
  • Cleans system-level temp directory (C:\Windows\Temp)
  • Silently skips locked or in-use files without crashing or prompting
  • No GUI window — launches a terminal (CMD) window showing real-time progress
  • Automatically exits after cleanup is complete
  • Packaged as a native Windows .exe installer via NSIS
  • Requests Administrator privileges at launch to ensure full access
  • Hardware acceleration disabled for minimal resource usage

Tech Stack

Technology Version Purpose
Electron ^29.0.0 Desktop application framework
Node.js v18+ Runtime environment & file system operations
electron-builder ^24.9.1 Packaging, installer generation (.exe)
Windows Batch Built-in Temp file deletion script
NSIS Built-in Windows installer system

Project Structure

clean-temp-files/
│
├── assets/
│   └── icon.ico              # Application icon (used in installer & taskbar)
│
├── dist/                     # Build output directory (auto-generated)
│
├── main.js                   # Electron main process — writes & executes .bat script
├── preload.js                # Preload script — context bridge setup (IPC ready)
├── package.json              # Project metadata, scripts, and electron-builder config
├── package-lock.json         # Locked dependency tree
├── .gitignore                # Git ignore rules
└── README.md                 # Project documentation

Prerequisites

Before running or building this project, ensure the following are installed on your system:

  • Node.js v18.0.0 or higher — Download here
  • npm v9.0.0 or higher (bundled with Node.js)
  • Windows operating system (10 or 11, 64-bit recommended)
  • Administrator access on the machine

To verify your setup:

node --version
npm --version

Installation

1. Clone the repository:

git clone https://github.com/helloanaroul/clean-temp-files.git

2. Navigate into the project directory:

cd clean-temp-files

3. Install all dependencies:

npm install

Usage

Run in Development Mode

Launches the Electron app directly from source without packaging:

npm start

Note: When running in development, Windows may prompt for Administrator privileges. Allow it for full functionality.


Build

Build NSIS Installer (Recommended)

Produces a standard Windows installer (.exe) with install/uninstall support, desktop shortcut, and Start Menu entry:

npm run build

Output: dist/Clean Temp Files Setup 1.0.0.exe

Build Portable Executable

Produces a single standalone .exe that requires no installation:

npm run build-portable

Output: dist/Clean Temp Files 1.0.0.exe

Build Configuration Summary

Setting Value
App ID com.cleantemp.app
Product Name Clean Temp Files
Target Platform Windows x64
Installer Type NSIS
One-Click Install Disabled (user chooses path)
Desktop Shortcut Created
Start Menu Shortcut Created
Execution Level requireAdministrator

How It Works

When the application is launched, the following sequence occurs:

  1. Electron startsmain.js is executed as the main process.
  2. Batch script is generated — A .bat script (clean_temp_runner.bat) is dynamically written to the system's temp directory using fs.writeFileSync.
  3. CMD window is spawned — The script is executed via cmd.exe using Node.js child_process.spawn, opening a visible terminal window that displays progress messages.
  4. Cleanup runs — The batch script deletes all files and subdirectories inside %TEMP% and C:\Windows\Temp, suppressing errors for locked files (>nul 2>&1).
  5. Electron quits — After a 500ms delay, app.quit() is called and the Electron process exits, leaving only the CMD window open until the batch script finishes.

Security & Permissions

Administrator Privileges

The package.json build configuration sets requestedExecutionLevel to requireAdministrator. This means Windows will display a UAC (User Account Control) prompt when the application is launched, requesting elevated permissions.

This is required to:

  • Access and delete files in C:\Windows\Temp
  • Remove files that standard users cannot delete

Context Isolation

The preload.js file uses Electron's contextBridge to expose a safe API (electronAPI) to the renderer process, maintaining proper context isolation between the main and renderer processes as per Electron security best practices.


Contributing

Contributions are welcome. To contribute:

  1. Fork the repository
  2. Create a new feature branch (git checkout -b feature/your-feature-name)
  3. Commit your changes (git commit -m "Add: your feature description")
  4. Push to the branch (git push origin feature/your-feature-name)
  5. Open a Pull Request

Please ensure your code is clean, well-commented, and tested on Windows before submitting.


License

This project is licensed under the MIT License. You are free to use, modify, and distribute this software for personal or commercial purposes, provided the original license and copyright notice are included.


Author

Md. Anarul Sarder GitHub: @helloanaroul


Built with Electron and Node.js — Designed for Windows.

About

A lightweight, open-source Windows desktop utility built with Electron and Node.js that automatically cleans temporary files from your system. Designed for simplicity, speed, and reliability — no GUI window, no unnecessary overhead. The application runs a batch script silently through a terminal window and exits immediately after completion.

Topics

Resources

Stars

Watchers

Forks

Contributors