Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
i have a batch that deletes vista and xp temp files. well im getting alot of process in use errors, how can i stop this. also please check my code and edit if you will please the temp locations because both vista and xp when converting to a exe both close but under batch dont.
xp:
del /f /q %windir%\Temp\*.*
del /f /s /q %systemdrive%\*.tmp
del /f /s /q %systemdrive%\*._mp
del /f /s /q %systemdrive%\*.log
del /f /s /q %systemdrive%\*.gid
del /f /s /q %systemdrive%\*.chk
del /f /s /q %systemdrive%\*.old
del /f /s /q %systemdrive%\recycled\*.*
del /f /s /q %windir%\*.bak
del /f /s /q %windir%\prefetch\*.*
del /f /q %userprofile%\cookies\*.*
del /f /q %userprofile%\recent\*.*
del /f /s /q "%userprofile%\Local Settings\Temporary Internet Files\*.*"
del /f /s /q "%userprofile%\Local Settings\Temp\*.*"
del /f /s /q "%userprofile%\recent\*.*"
vista:
el /f /s /q %systemdrive%\*.tmp
del /f /s /q %systemdrive%\*._mp
del /f /s /q %systemdrive%\*.log
del /f /s /q %systemdrive%\*.gid
del /f /s /q %systemdrive%\*.chk
del /f /s /q %systemdrive%\*.old
del /f /s /q "%appdata%\Microsoft\Windows\cookies\*.*"
del /f /s /q "%userprofile%\Local Settings\Temporary Internet Files\*.*"
del /f /s /q "%userprofile%\Local Settings\Temp\*.*"
del /f /s /q "%appdata%\Microsoft\Windows\Recent\*.*" >>
del /f /s /q %windir%\*.bak
del /f /s /q %windir%\prefetch\*.*
del /f /s /q %windir%\SoftwareDistribution\Download\*.*
rd /s /q "%userprofile%\Local Settings\Temp\" & md "%userprofile%\Local Settings\Temp\"
rd /s /q %windir%\Temp & md %windir%\TempThanks Brock

If your getting process in use errors the problem is simple, something is still using the file and has it locked so you can't delete it.
I know your trying to reclaim disk space but some of these files are still serving their purpose.
You could suppress the error messages by redirecting stderr into nul. The problem would still exist but you would not have to see the messages.
2>nul del ......

If it works as a .bat or .cmd and doesn't work after being "compiled" to an exe there is a good reason. Many batch "compilers" simply compress the script with a stub of code that extracts batch file into the temp directory, like Bat To Exe converter from Fatih Kodak.
This means you script is deleting itself....
Here is a little test to "compile" into an exe so you can see what I mean.
echo The script is located at "%~f0" pause start notepad "%~f0" pause

I have yet to see a bat compiler that works.
=====================================
If at first you don't succeed, you're about average.M2

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |