Boost PC & Reduce Lag with Automated Windows Batch Script

Over extended periods of use, Windows 10 and Windows 11 machines accumulate thousands of temporary cache files, broken DNS cache records, and stale software installer logs. This buildup causes sluggish application launch times, unexplained disk clutter on drive C, and micro-stuttering during gaming sessions.
How the BAT Script Works: A .bat (Batch file) is a lightweight script containing pre-written Microsoft Windows Command Prompt (CMD) commands. Rather than manually typing dozens of terminal commands, the script executes the entire disk cleanup, DNS cache flushing, and system maintenance sequence automatically with a single click.
Optimization Modules Included in the Batch Script
All operations rely entirely on native Windows administration binaries, ensuring zero third-party background bloat:
| Maintenance Category | Primary Commands | System Benefit |
|---|---|---|
| Temporary Cache Purging | del /q /f /s %temp%\*cleanmgr /sagerun:1 |
Deletes obsolete Temp, Prefetch, and crash dump files, reclaiming between 3GB and 20GB of disk space. |
| Network & Socket Reset | ipconfig /flushdnsnetsh winsock reset |
Clears corrupted DNS mappings and resets the network socket layer to eliminate ping spikes and packet drops. |
| System File Integrity Check | sfc /scannowchkdsk /f (optional) |
Scans for corrupted system DLLs and automatically restores healthy copies from the component store. |
| Drive Cache Optimization | fsutil behavior set DisableLastAccess 1 |
Disables the unnecessary last-access timestamp recording on files, reducing redundant write cycles on SSDs. |
Script Source Code Preview
You can open the script with Notepad at any time to inspect the code before execution:
@echo offtitle Osteup - Windows Clean & Optimize Scriptecho Cleaning system temporary cache...del /s /f /q %userprofile%\AppData\Local\Temp\*.* >nul 2>&1del /s /f /q C:\Windows\Temp\*.* >nul 2>&1del /s /f /q C:\Windows\Prefetch\*.* >nul 2>&1echo Flushing DNS cache and network sockets...ipconfig /flushdns >nul 2>&1echo Optimizing file system cache behavior...fsutil behavior set DisableLastAccess 1 >nul 2>&1echo System maintenance completed successfully!pauseStep-by-Step Usage Guide
Follow these steps to ensure full execution without "Access Denied" permission errors:
- Download the archive from the link below and unpack it using password
osteup. - Close all open applications, browser tabs, and background work to allow locked temporary files to be cleaned.
- Right-click the .bat file and choose Run as administrator.
- A command prompt window will appear and process each cleanup step automatically over 30 to 90 seconds.
- Once the finished prompt appears, press any key to close the window and restart your PC to finalize all configuration changes.
Crucial Requirement: You must launch the file as Administrator. Running it via standard double-click will cause Windows to block deletions inside protected directories like C:\Windows\Temp.
osteup
Frequently Asked Questions
Will this batch script delete my personal documents or photos?
No. The script strictly targets temporary directories (AppData\Local\Temp, Windows\Temp, Prefetch) and system cache stores. Your personal files on Desktop, Documents, Downloads, and secondary drives remain completely untouched.
Why does Windows SmartScreen display a prompt when downloading?
Because .bat files contain executable script instructions, web browsers and Windows Defender flag them conservatively. This is a standard false positive. You can right-click the file and click Edit to review every command line in plaintext before running.
How frequently should I execute this optimization script?
Running the maintenance script once every 1 to 2 weeks, or immediately following major Windows cumulative updates, is optimal for keeping cache buildup under control.
Related Articles

BrotX Optimizer v7: Rootless Android System Tuning via Shizuku ADB
Guide to rootless Android system tuning with BrotX Optimizer v7 via Shizuku ADB: enable ANGLE Vulkan GPU, 0ms floating window touch, 80% charge protection, and 58 flags.

iOS Debloat Script: Optimize Performance, Battery Life and Gaming FPS on Jailbroken iPhone
Complete guide to perf.sh iOS debloat script disabling 100+ telemetry and background daemons to reclaim RAM, eliminate thermal throttling, and boost gaming FPS.

OOptimize: Android 7-15 Gaming Tweaks (Root & No-Root)
Optimize SurfaceFlinger and GPU Vulkan pipeline on Android 7-15 with OOptimize: stabilize FPS, eliminate frame drops, and minimize touch input latency.

RAM Purger: Stop Background Processes & Boost Android Gaming Like iPhone
Complete guide to the rootless RAM Purger (frozen.sh) shell script terminating 400+ background app tasks to reclaim RAM and eliminate frame drops on Android.
Comments(0)
Sign in to join the conversation
Sign in with Google, Facebook or Email to leave a comment and get notified of replies.
No comments yet. Be the first to join the conversation!