Unfortunately this only works for the current user. Not all profiles at once. Thanks for the attempt though.
Main Topics
Browse All TopicsI am trying to write an efficient batch file to do some cleanup for systems in our network prior to recreating new systems and copying some saved files over to the new computer.
The following is what I am trying to clean up....
--------------------------
User Specific files:
C:\Documents and Settings\user\Local Settings\History
C:\Documents and Settings\user\Local Settings\Temp
C:\Documents and Settings\user\Local Settings\Temporary Internet Files\Content.IE5
General System files:
C:\WINNT\Temp
C:\WINNT\system32\spool\PR
--------------------------
I am having problems deleting the files from these two directories
C:\Documents and Settings\radams\Local Settings\History
C:\Documents and Settings\radams\Local Settings\Temp
I am looking to delete all files in these two folders for every person/profile on the system. Some systems may have 5 or more profiles on them.
The following code works for everything else except these two folders. What am I missing?
Any assistance would be appreciated.
--------------------------
SET SRC1=C:\Documents and Settings
SET SRC2=Local Settings\Temporary Internet Files\Content.IE5
SET SRC3=Local Settings\History
SET SRC4=Local Settings\Temp
FOR /D %%X IN ("%SRC1%\*") DO FOR /D %%Y IN ("%%X\%SRC2%\*.*") DO RMDIR /S /Q "%%Y"
del "C:\winnt\system32\spool\P
del "C:\winnt\temp\*.*" /f /s /q
exit
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
OK try
Delete Cookies\Temp Internet, using VB (don’t panic its easy!)
source: http://support.microsoft.c
Paste the text below (not the ****) into notepad and save as "delete.vbs"
Then simply run the file
**************************
Option Explicit
Private Declare Function FindFirstUrlCacheGroup Lib "wininet.dll" ( _
ByVal dwFlags As Long, _
ByVal dwFilter As Long, _
ByRef lpSearchCondition As Long, _
ByVal dwSearchCondition As Long, _
ByRef lpGroupId As Date, _
ByRef lpReserved As Long) As Long
Private Declare Function FindNextUrlCacheGroup Lib "wininet.dll" ( _
ByVal hFind As Long, _
ByRef lpGroupId As Date, _
ByRef lpReserved As Long) As Long
Private Declare Function DeleteUrlCacheGroup Lib "wininet.dll" ( _
ByVal sGroupID As Date, _
ByVal dwFlags As Long, _
ByRef lpReserved As Long) As Long
Private Declare Function FindFirstUrlCacheEntry Lib "wininet.dll" Alias "FindFirstUrlCacheEntryA" ( _
ByVal lpszUrlSearchPattern As String, _
ByRef lpFirstCacheEntryInfo As INTERNET_CACHE_ENTRY_INFO,
ByRef lpdwFirstCacheEntryInfoBuf
Private Type INTERNET_CACHE_ENTRY_INFO
dwStructSize As Long
szRestOfData(1024) As Long
End Type
Private Declare Function DeleteUrlCacheEntry Lib "wininet.dll" Alias "DeleteUrlCacheEntryA" ( _
ByVal lpszUrlName As Long) As Long
Private Declare Function FindNextUrlCacheEntry Lib "wininet.dll" Alias "FindNextUrlCacheEntryA" ( _
ByVal hEnumHandle As Long, _
ByRef lpNextCacheEntryInfo As INTERNET_CACHE_ENTRY_INFO,
ByRef lpdwNextCacheEntryInfoBuff
Private Const CACHGROUP_SEARCH_ALL = &H0
Private Const ERROR_NO_MORE_FILES = 18
Private Const ERROR_NO_MORE_ITEMS = 259
Private Const CACHEGROUP_FLAG_FLUSHURL_O
Private Const BUFFERSIZE = 2048
Private Sub Command1_Click()
Dim sGroupID As Date
Dim hGroup As Long
Dim hFile As Long
Dim sEntryInfo As INTERNET_CACHE_ENTRY_INFO
Dim iSize As Long
On Error Resume Next
' Delete the groups
hGroup = FindFirstUrlCacheGroup(0, 0, 0, 0, sGroupID, 0)
' To avoid error using it with IE4 as FindFirstUrlCacheGroup is not implemented
If Err.Number <> 453 Then
If (hGroup = 0) And (Err.LastDllError <> 2) Then
MsgBox "An error occurred enumerating the cache groups" & Err.LastDllError
Exit Sub
End If
Else
Err.Clear
End If
If (hGroup <> 0) Then
'we succeeded in finding the first cache group.. enumerate and
'delete
Do
If (0 = DeleteUrlCacheGroup(sGroup
' To avoid error using it with IE4 as FindFirstUrlCacheGroup is not implemented
If Err.Number <> 453 Then
MsgBox "Error deleting cache group " & Err.LastDllError
Exit Sub
Else
Err.Clear
End If
End If
iSize = BUFFERSIZE
If (0 = FindNextUrlCacheGroup(hGro
MsgBox "Error finding next url cache group! - " & Err.LastDllError
End If
Loop Until Err.LastDllError = 2
End If
' Delete the files
sEntryInfo.dwStructSize = 80
iSize = BUFFERSIZE
hFile = FindFirstUrlCacheEntry(0, sEntryInfo, iSize)
If (hFile = 0) Then
If (Err.LastDllError = ERROR_NO_MORE_ITEMS) Then
GoTo done
End If
MsgBox "ERROR: FindFirstUrlCacheEntry - " & Err.LastDllError
Exit Sub
End If
Do
If (0 = DeleteUrlCacheEntry(sEntry
And (Err.LastDllError <> 2) Then
Err.Clear
End If
iSize = BUFFERSIZE
If (0 = FindNextUrlCacheEntry(hFil
MsgBox "Error: Unable to find the next cache entry - " & Err.LastDllError
Exit Sub
End If
Loop Until Err.LastDllError = ERROR_NO_MORE_ITEMS
done:
MsgBox "cache cleared"
Command1.Enabled = True
End Sub
**************************
Ok, I was able to figure this one out. Here is my own answer that works 99.5% There are a few small files that remain but I can live with them. The last two lines with the DEL command deletes the files from History and Temp unless another program still has the files in use. (Locked open)
I ran this on a system with 30 users and approx 15 meg of junk files and deleted the unnecessary junk in less than two minutes.
Hope This helps everyone.
We use Windows 2000 Pro in a domain with thousands of users and rebuild up to 100 computers each month.
--------------------------
SET SRC1=C:\Documents and Settings
SET SRC2=Local Settings\Temporary Internet Files\Content.IE5
SET SRC3=Local Settings\History
SET SRC4=Local Settings\Temp
FOR /D %%X IN ("%SRC1%\*") DO FOR /D %%Y IN ("%%X\%SRC2%\*.*") DO RMDIR /S /Q "%%Y"
FOR /D %%X IN ("%SRC1%\*") DO FOR /D %%Y IN ("%%X\%SRC3%\*.*") DO RMDIR /S /Q "%%Y"
FOR /D %%X IN ("%SRC1%\*") DO FOR /D %%Y IN ("%%X\%SRC4%\*.*") DO RMDIR /S /Q "%%Y"
FOR /D %%X IN ("%SRC1%\*") DO FOR %%Y IN ("%%X\%SRC3%\*.*") DO DEL /F /S /Q "%%Y"
FOR /D %%X IN ("%SRC1%\*") DO FOR %%Y IN ("%%X\%SRC4%\*.*") DO DEL /F /S /Q "%%Y"
exit
Here is a slightly expanded version of RDAdams's script, removes files from WINNT\temp and [Profilename]\Recent too.
@ECHO OFF
SET SRC1=C:\Documents and Settings
SET SRC2=Local Settings\Temporary Internet Files\Content.IE5
SET SRC3=Local Settings\History
SET SRC4=Local Settings\Temp
SET SRC5=Recent
echo About to delete files from Internet Explorer "Temporary Internet files"
FOR /D %%X IN ("%SRC1%\*") DO FOR /D %%Y IN ("%%X\%SRC2%\*.*") DO RMDIR /S /Q "%%Y"
echo About to delete files from Internet Explorer "History"
FOR /D %%X IN ("%SRC1%\*") DO FOR /D %%Y IN ("%%X\%SRC3%\*.*") DO RMDIR /S /Q "%%Y"
FOR /D %%X IN ("%SRC1%\*") DO FOR %%Y IN ("%%X\%SRC3%\*.*") DO DEL /F /S /Q "%%Y"
echo About to delete files from "Local settings\temp"
FOR /D %%X IN ("%SRC1%\*") DO FOR /D %%Y IN ("%%X\%SRC4%\*.*") DO RMDIR /S /Q "%%Y"
FOR /D %%X IN ("%SRC1%\*") DO FOR %%Y IN ("%%X\%SRC4%\*.*") DO DEL /F /S /Q "%%Y"
echo About to delete files from "Recent" i.e. what appears in Start/Documents/My Documents
FOR /D %%X IN ("%SRC1%\*") DO FOR %%Y IN ("%%X\%SRC5%\*.lnk") DO DEL /F /S /Q "%%Y"
echo About to delete files from "Windows\Temp"
cd /d %SystemRoot%\temp
del /F /Q *.*
@echo Y|RD /S ""
exit
Hi manch03 sorry for not responding earlier. Take the information for the script and put in in notepad and save as namex.bat then within windows Start > Run > namex.bat to run the file.
Hi Jimbob60, the reason we didn't include the winnt\temp and profile recent in our batch file is some programs put information there we did not want to remove. Custom programs our company developed. But for most applications this is a good addition.
Thanks
After reading your question I would ask you to see if the file exists in the directory on the target computer first. You don't have to log onto the computer to check this. Use another computer and just open the c drive using start > run > \\targetcomputername\c$ then browse to the directory in question and see what files are there. If it is then running the script would probably eliminate the error. A more direct way to eliminate just this one file would be to add the script to remove just that one file that is causing the problems. This would speed up the execution of your AD login script.
Ok... sorry for attaching myself after all the work you guys did. Not sure if I should even post here but my question is similar to RDAdams.
I am trying to delete cached profiles on multiple W2K systems that have hundreds of users within a few months. We have restrictive roaming profiles but there is still enough data being stored that the hard-drives are filling up too frequently. The users are informed and save the majority of their data on server shares. I need a script or batch file that will allow me to delete profiles that are ... say over 2 weeks old. I realize GP would do this but it would take several months and many pulled teeth to accomplish. Any suggestions... i am very novice when it comes to this. Let me know if i need to post a new topic in order to award points.
thanks
Hi there,
I have been searching for this for ages.
Servicing XP machines with multiple profiles is a real pain for us, but I was just wondering if you could explain to me what is actualy happening in one line in the batch file.
I have a fairly good knowledge of Batch files and some knowledge of using variables.
FOR /D %%X IN ("%SRC1%\*") DO FOR /D %%Y IN ("%%X\%SRC2%\*.*") DO RMDIR /S /Q "%%Y"
1. What is the "FOR /D %%X IN " doing exactly
2. Why is this there a Y and not an X like at the start here "DO FOR /D %%Y IN"
3. The /Q at the end I assume is not asking for confirmation
If you can answer these that we be great thanks
Mark
In regards to your questions:
1. What is the "FOR /D %%X IN " doing exactly - It conditionally performs a command on several folders versus the "FOR" command which runs a specified command for each file in a set of files.
2. Thre are two variables being used in the batchfile, hence %%x and %%y.
3. The /Q switch is for Quiet mode. Using it means you will do not have to give a Yes/No Prompt before deleting.
Here is my question, I created a simpler version of this, which I listed below. It runs fine from the command line, but I f I try to execute it using the Task Scheduler, I receive the following error: Result: The task completed with an exit code of (3). I am using the local system account to operate the Task Scheduler Service and a Domain Admin account that has local Admin access to the particular test machine. Any ideas? Thanks in advance!
@ECHO OFF
SET SRC1=C:\Documents and Settings
SET SRC2=Local Settings\Temporary Internet Files\Content.IE5
SET SRC3=Local Settings\Temp
echo About to delete files from Internet Explorer "Temporary Internet files"
FOR /D %%X IN ("%SRC1%\*") DO FOR /D %%Y IN ("%%X\%SRC2%\*.*") DO RMDIR /S /Q "%%Y"
echo About to delete files from "Local settings\temp"
FOR /D %%X IN ("%SRC1%\*") DO FOR /D %%Y IN ("%%X\%SRC3%\*.*") DO RMDIR /S /Q "%%Y"
FOR /D %%X IN ("%SRC1%\*") DO FOR %%Y IN ("%%X\%SRC3%\*.*") DO DEL /F /S /Q "%%Y"
echo About to delete files from "Windows\Temp"
cd /d %SystemRoot%\temp
del /F /Q *.*
@echo Y|RD /S ""
exit
Hi Guys,
Can any one tell me where I can find a list of XP variable (like %SystemRoot% for c:\windows ?)
Many thanks to Jonnydd and RDAdams for the batch file but the problem is that
1. the batch file is hard coded to set the variable one to be C:\Documents and Settings.
Many machines come into us with XP running from D:\ (don't ask me why)
2. I copied the batch file to a floppy and tried to run it on another machine from the floppy, the batch file ran and finished with
no errors but when I went to look at the floppy it was empty.
Again the batch file starts runing from where ever you opened the file from, if you run the batch file from your C: then it is ok but I started the batch file from the floppy and so it skipped the first 4 lines of the code because those directories didn't exist on the A: and then del /F /Q *.*
I want a %variable% that goes to where windows is installed (ie. c: if windows is on c drive d: if windows is on d drive etc)
that i can put in instead of C:\Documents and Settings in the 2nd line and then also bfore starting to delete any files change to that drive so i can run it from a floppy?
Cheers
Mark
common ones http://kennethhunt.com/arc
How about adding a IF statement to see if C:\Documents and Settings exists, duplicate
IF EXIST D:\Documents and Settings GOTO ALTDrive
SET SRC1=C:\Documents and Settings
SET SRC2=Local Settings\Temporary Internet Files\Content.IE5
SET SRC3=Local Settings\History
SET SRC4=Local Settings\Temp
FOR /D %%X IN ("%SRC1%\*") DO FOR /D %%Y IN ("%%X\%SRC2%\*.*") DO RMDIR /S /Q "%%Y"
FOR /D %%X IN ("%SRC1%\*") DO FOR /D %%Y IN ("%%X\%SRC3%\*.*") DO RMDIR /S /Q "%%Y"
FOR /D %%X IN ("%SRC1%\*") DO FOR /D %%Y IN ("%%X\%SRC4%\*.*") DO RMDIR /S /Q "%%Y"
FOR /D %%X IN ("%SRC1%\*") DO FOR %%Y IN ("%%X\%SRC3%\*.*") DO DEL /F /S /Q "%%Y"
FOR /D %%X IN ("%SRC1%\*") DO FOR %%Y IN ("%%X\%SRC4%\*.*") DO DEL /F /S /Q "%%Y"
exit
ALTDrive
SET SRC1=D:\Documents and Settings
SET SRC2=Local Settings\Temporary Internet Files\Content.IE5
SET SRC3=Local Settings\History
SET SRC4=Local Settings\Temp
FOR /D %%X IN ("%SRC1%\*") DO FOR /D %%Y IN ("%%X\%SRC2%\*.*") DO RMDIR /S /Q "%%Y"
FOR /D %%X IN ("%SRC1%\*") DO FOR /D %%Y IN ("%%X\%SRC3%\*.*") DO RMDIR /S /Q "%%Y"
FOR /D %%X IN ("%SRC1%\*") DO FOR /D %%Y IN ("%%X\%SRC4%\*.*") DO RMDIR /S /Q "%%Y"
FOR /D %%X IN ("%SRC1%\*") DO FOR %%Y IN ("%%X\%SRC3%\*.*") DO DEL /F /S /Q "%%Y"
FOR /D %%X IN ("%SRC1%\*") DO FOR %%Y IN ("%%X\%SRC4%\*.*") DO DEL /F /S /Q "%%Y"
exit
Yea i suppose that would work, I think i've only ever had one person in with XP running from E drive but it does happen.
The problem is we are running a computer service centre and we get a lot of people who have tried to fix thier computer by sticking in the windows cd. All that ends up happening is they get one bootable version on C: and one bootable version on D: this happens alot for us.
The problem with the IF statement is that there would be a c:\docs and settings but it wouldn't necesarily be the one that was being used?
Sorry if that doesn't make sence have been trying to get this working 4 a few days along with single click reg file that sets everything up [the way it should have been by default :-; ] and the other batch files for instlling software and updating on all existing profiles from a single click (have gone boggle eyed now my stomach and brain are telling me to unplug for a bit)
I found that runing the %HOMEDRIVE% returns me back c:\> on my PC hich i what I want but I think if I use that in a batch file and I use it on a business machine which has the %HOMEDRIVE% set to a share on a server I could really do damage,
Also running %HOMEPATH% gave me c:\Documents and settings\mark> which is almost the correct thing, again would be worried if this had been set to a network share!!!
Any way going to rest my bones now, Will check in inthe morning to see if any one has found anyting,
Thanks again
Mark
Hello Ben, try the following. SRC5 directory
and new line in action statements to act on SRC5 (see the ninth line)
__________________________
SET SRC1=C:\Documents and Settings
SET SRC2=Local Settings\Temporary Internet Files\Content.IE5
SET SRC3=Local Settings\History
SET SRC4=Local Settings\Temp
SET SRC5=Local Settings
FOR /D %%X IN ("%SRC1%\*") DO FOR /D %%Y IN ("%%X\%SRC2%\*.*") DO RMDIR /S /Q "%%Y"
FOR /D %%X IN ("%SRC1%\*") DO FOR /D %%Y IN ("%%X\%SRC3%\*.*") DO RMDIR /S /Q "%%Y"
FOR /D %%X IN ("%SRC1%\*") DO FOR /D %%Y IN ("%%X\%SRC4%\*.*") DO RMDIR /S /Q "%%Y"
FOR /D %%X IN ("%SRC1%\*") DO FOR /D %%Y IN ("%%X\%SRC5%\*.*") DO RMDIR /S /Q "%%Y"
FOR /D %%X IN ("%SRC1%\*") DO FOR %%Y IN ("%%X\%SRC3%\*.*") DO DEL /F /S /Q "%%Y"
FOR /D %%X IN ("%SRC1%\*") DO FOR %%Y IN ("%%X\%SRC4%\*.*") DO DEL /F /S /Q "%%Y"
exit
Hi Guys,
Got this one sorted with system variables :-) and when run on XP and 2000 will clean all profiles at once.
You cannot batch delete content.ie5 for the profile that you are logged into we get around this by booting in safe mode and logging in as administrator
Copy and past into notepad and save as a batch file.
Remember the confirmation Y is case sensative. (sorry about the long post could see how to post with attachment)
**************************
cls
@echo off
:start
cls
@ECHO.
@ECHO.
@ECHO.
@ECHO **************************
@ECHO **** ****
@ECHO **** PLEASE CHECK TO SEE IF THIS IS YOUR SYSTEM DRIVE ****
@ECHO **** ****
@ECHO **** ****
@ECHO **** ****
@ECHO **** -- %HOMEDRIVE% -- ****
@ECHO **** ****
@ECHO **** This is intended for NT based systems ONLY ****
@ECHO **** ****
@ECHO **************************
@ECHO.
@ECHO.
@ECHO.
set choice=
set /p choice=Type Y or N to continue:
if not '%choice%'=='' set choice=%choice:~0,1%
if '%choice%'=='Y' goto clean2
if '%choice%'=='N' goto bye
@ECHO " %choice% " is not valid please try again (Y or N are case sensative)
@ECHO.
@echo.
PAUSE
goto start
:clean2
cls
SET SRC1=%SYSTEMDRIVE%\Documen
SET SRC2=Local Settings\Temporary Internet Files\Content.IE5
SET SRC3=Local Settings\Temp
echo About to delete files from Internet Explorer "Temporary Internet files"
FOR /D %%X IN ("%SRC1%\*") DO FOR /D %%Y IN ("%%X\%SRC2%\*.*") DO RMDIR /S /Q "%%Y"
echo About to delete files from "Local settings\temp"
FOR /D %%X IN ("%SRC1%\*") DO FOR /D %%Y IN ("%%X\%SRC3%\*.*") DO RMDIR /S /Q "%%Y"
FOR /D %%X IN ("%SRC1%\*") DO FOR %%Y IN ("%%X\%SRC3%\*.*") DO DEL /F /S /Q "%%Y"
echo About to delete files from "Windows\Temp"
cd\
%systemdrive%
cd /d %SystemRoot%\temp
del /F /Q *.*
@echo Y|RD /S ""
@echo.
@echo.
@echo Please review any errors if they exist
@echo.
@echo.
PAUSE
goto end
:clean
cls
SET drive=%SYSTEMDRIVE%
SET SRC1=%drive%\Documents and Settings
SET SRC2=Local Settings\Temporary Internet Files
SET SRC3=Local Settings\History
SET SRC4=Local Settings\Temp
SET SRC5=%SYSTEMROOT%\Temp
@echo.
@echo.
@echo About to delete Temporary Internet Files
@echo.
FOR /D %%X IN ("%SRC1%\*") DO FOR /D %%Y IN ("%%X\%SRC2%\*.*") DO RMDIR /S /Q "%%Y"
@echo.
@echo About to delete History
@echo.
FOR /D %%X IN ("%SRC1%\*") DO FOR /D %%Y IN ("%%X\%SRC3%\*.*") DO RMDIR /S /Q "%%Y"
@echo.
@echo About to delete Temp
@echo.
FOR /D %%X IN ("%SRC1%\*") DO FOR /D %%Y IN ("%%X\%SRC4%\*.*") DO RMDIR /S /Q "%%Y"
FOR /D %%X IN ("%SRC1%\*") DO FOR %%Y IN ("%%X\%SRC3%\*.*") DO DEL /F /S /Q "%%Y"
FOR /D %%X IN ("%SRC1%\*") DO FOR %%Y IN ("%%X\%SRC4%\*.*") DO DEL /F /S /Q "%%Y"
@echo.
@echo About to delete System Temp
cd\
%systemdrive%
cd %SRC5%
del /F /Q *.*
@echo.
@echo.
@echo Please review any errors if they exist
@echo.
@echo.
PAUSE
goto end
:bye
cls
@echo.
@echo.
@echo **********You have chosen to exit the batch file**********
@echo Please check on which drive Documents and Settings resides
@echo **************************
@echo.
@echo.
Pause
goto end
:end
cls
**************************
Just a quick note to RDAdams regarding clearing out Cookies using his method posted on 10/11/2004 05:35AM PDT:
SET SRC5=Local Settings
and
FOR /D %%X IN ("%SRC1%\*") DO FOR /D %%Y IN ("%%X\%SRC5%\*.*") DO RMDIR /S /Q "%%Y"
This removed the temp directory from "C:\Documents and Settings\[username]\Local Settings\Temp" on my Windows 2000 PC (and did not delete the cookies).
I replaced the two lines with
SET SRC5=Cookies
and
FOR /D %%X IN ("%SRC1%\*") DO FOR %%Y IN ("%%X\%SRC5%\*.txt") DO DEL /F /S /Q "%%Y"
This cleared out the Cookies correctly.
IT's Working we added below things in Batch Files
--------------------------
cls
SET SRC1=%SYSTEMDRIVE%\Documen
SET SRC2=Local Settings\Temporary Internet Files\Content.IE5
SET SRC3=Local Settings\Temp
SET SRC4=Local Settings\History
SET SRC5=%SYSTEMROOT%\Temp
SET SRC6=Cookies
echo About to delete files from Internet Explorer "Temporary Internet files"
FOR /D %%X IN ("%SRC1%\*") DO FOR /D %%Y IN ("%%X\%SRC2%\*.*") DO RMDIR /S /Q "%%Y"
echo About to delete files from "Local settings\temp"
FOR /D %%X IN ("%SRC1%\*") DO FOR /D %%Y IN ("%%X\%SRC3%\*.*") DO RMDIR /S /Q "%%Y"
FOR /D %%X IN ("%SRC1%\*") DO FOR %%Y IN ("%%X\%SRC3%\*.*") DO DEL /F /S /Q "%%Y"
echo About to delete files from "Windows\Temp"
cd\
%systemdrive%
cd /d %SystemRoot%\temp
del /F /Q *.*
@echo Y|RD /S ""
@echo.
@echo.
echo About to delete files from "Local Settings\History"
FOR /D %%X IN ("%SRC1%\*") DO FOR %%Y IN ("%%X\%SRC4%\*.*") DO DEL /F /S /Q "%%Y"
FOR /D %%X IN ("%SRC1%\*") DO FOR %%Y IN ("%%X\%SRC4%\today*.*") DO DEL /F /S /Q "%%Y"
FOR /D %%X IN ("%SRC1%\*") DO FOR %%Y IN ("%%X\%SRC4%\*.*") DO DEL /F /S /Q "%%Y"
echo About to delete files from "%SYSTEMROOT%\Temp"
FOR /D %%X IN ("%SRC1%\*") DO FOR %%Y IN ("%%X\%SRC5%\*.*") DO DEL /F /S /Q "%%Y"
echo About to delete files from "Cookies"
FOR /D %%X IN ("%SRC1%\*") DO FOR %%Y IN ("%%X\%SRC6%\*.*") DO DEL /F /S /Q "%%Y"
@echo Please review any errors if they exist
@echo.
@echo.
--------------------------
This section is a bit redundant:
echo About to delete files from "%SYSTEMROOT%\Temp"
FOR /D %%X IN ("%SRC1%\*") DO FOR %%Y IN ("%%X\%SRC5%\*.*") DO DEL /F /S /Q "%%Y"
Basically, you're telling the computer:
"For Each Folder in 'C:\Documents and Settings', Delete all files in 'C:\Windows\Temp\*.*'"
So you're running the DEL command multiple times, depending on how many user profile folders are in the Docs and Settings folder.
Also, since it's just the one folder you're deleting from, can't you just get rid of the FOR/DO loop altogether? Like this:
DEL %SYSTEMROOT%\Temp\*.* /F /S /Q
Or am I missing something obvious?
Business Accounts
Answer for Membership
by: PeteLongPosted on 2003-11-11 at 11:29:13ID: 9724859
Hi RDAdams, e.com/Oper ating_Syst ems/Win200 0/ Q_205774 52.html?qu ery=batch+ delete+tem p+internet & searchTyp e=topic
http://www.experts-exchang
PeteL