Speed Up Visual Studio by Clearing Temp Directories on Windows

.NET development can be brutal on a system; particularly web development. I created a simple batch file that (when run as admin) cleans up a lot of the temp directories that Visual Studio likes to fill up.

  1. Copy and paste the code below into a batch file (filename.bat).
  2. Temp directories may vary depending on OS.
  3. Update the framework version to the correct version(s) you’re using.
  4. Save the file.
  5. Right-click and Run as Admin.

@REM Restart local IIS.Start iisreset

@REM Delete everything from user local temp directory and localhost temp directories.
del /q "C:\Users\%username%\AppData\Local\Temp\*"FOR /D %%p IN ("C:\Users\%username%\AppData\Local\Temp\*.*") DO rmdir "%%p" /s /q

@REM Delete based on version(s) of .NETdel /q "C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\*" FOR /D %%p IN ("C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\*.*") DO rmdir "%%p" /s /q

pause

Leave a Reply