Cleanup temp files and maintenance log v1.0.bat is a Windows Batch (.bat) script designed to perform routine system maintenance by safely cleaning temporary files and selected Windows maintenance log directories.
The script includes structured logging, user interaction via a menu-driven interface, and safeguards to avoid unintended deletions.
This script is intended for IT administrators, support technicians, and advanced users performing local system maintenance on Windows devices.
-
Menu-driven interface for ease of use
-
Cleans common Windows and application temporary directories
-
Cleans Windows maintenance logs (CBS and DISM)
-
Per-run log file with timestamp
-
Locale-independent timestamps
-
File-level delete tracking (attempted, deleted, skipped)
-
Safe handling of:
- Missing directories
- Locked files
- Read-only, system, and hidden files
- Reparse points (junctions/symlinks)
| Property | Value |
|---|---|
| Script Name | Cleanup temp files and maintenance log v1.0.bat |
| Version | 1.0 |
| Script Type | Windows Batch Script |
| Execution Context | Local user or elevated administrator |
| Logging | Enabled (per execution) |
- Windows 10 or later
- Command Prompt (
cmd.exe) - PowerShell available in system PATH (used for timestamp generation)
- NTFS file system
- Recommended: Run as Administrator for full cleanup capability
C:\IT Maintenance Logs
Cleanup_temp_files_and_maintenance_log_v1.0_run_by_username_on_YYYY-MM-DD_HHMMSS.log
Each execution creates a new log file, ensuring historical runs are preserved.
Cleans the following directories (if present):
%USERPROFILE%\AppData\LocalLow\NVIDIA\DXCache%USERPROFILE%\AppData\Local\NVIDIA\DXCache%USERPROFILE%\AppData\Local\TempC:\Windows\PrefetchC:\Windows\SoftwareDistribution\DownloadC:\Windows\Temp
Cleans the following Windows log directories:
C:\Windows\Logs\CBSC:\Windows\Logs\DISM
Opens the log directory in Windows Explorer.
Gracefully exits the script and finalizes logging.
-
Logs are written throughout execution
-
Script continues running even if logging fails
-
Each deletion attempt is logged as:
DELETEDSKIPPED (delete failed)SKIPPED (missing folder)
-
Directory removals are logged separately
-
A summary section is written after each cleanup operation
- Does not delete user documents or system-critical folders
- Reparse points (junctions and symbolic links) are detected and skipped
- Directory deletions occur only after files are processed
- Read-only, system, and hidden attributes are removed only to allow deletion
- Script does not terminate on individual errors
- Copy the
.batfile to a local machine - Right-click the file
- Select Run as administrator (recommended)
- Choose an option from the menu
You may safely modify:
LOG_DIRto change log storage location- Cleanup target paths under
:OPT1and:OPT2 - Script name and version variables
Do not modify delayed expansion or logging subroutines unless you understand batch scripting behavior.
- Locked files may be skipped
- Some Windows folders require elevation
- PowerShell must be available for timestamp creation
- Batch scripting does not provide transactional rollback
This script is provided as-is and is suitable for internal IT use. Test modifications in a non-production environment before deployment.
- Initial release
- Menu-driven cleanup
- Structured logging
- File-level counters and summary reporting
Internal use / organizational use. No warranty is expressed or implied.
This script is provided “as-is” without warranty. Use at your own risk. Always test in a controlled environment before use.
- Owner: Max Timmers
- Contact: maxtimmers@live.com
- Last Updated: 19-DEC-2025