ComputerTechie
asked on
Delete temp and IE cache files
Hello fellow tech,
I have a scripts from a while ago the allow me to delete temp file and internet cache files.
Today the temp and ie one stop working and not sure where i when wrong.
It delete the temp and not the internet cache.
I know it got to be an easy fix just not seeing it.
Thanks all, CT
I have a scripts from a while ago the allow me to delete temp file and internet cache files.
Today the temp and ie one stop working and not sure where i when wrong.
It delete the temp and not the internet cache.
I know it got to be an easy fix just not seeing it.
Thanks all, CT
@echo off
taskkill /f /t /im iexplore.exe
cls
setlocal
cls
set UserRoot=C:\Documents and settings
set UserRoot2=c:\users
cls
REM *** Process all profile folders:
cls
for /d %%a in ("%UserRoot%\*.*") do call :process "%%a"
cls
REM *** Process the system temp folder:
cls
del /F /S /Q "c:\windows\temp\*.*" /s
cls
del /F /S /Q "c:\windows\system32\temp\*.*" /s
cls
del /F /S /Q "c:\windows\*.tmp" /s
cls
del /F /S /Q "c:\windows\*.temp" /s
cls
del /F /S /Q "c:\windows\system32\*.temp /s
cls
del /F /S /Q "c:\windows\system32\*.tmp" /s
cls
del /F /S /Q "c:\windows\prefetch\*.*" /s
cls
rd /s /q "c:\windows\temp"
cls
md "c:\windows\temp
cls
rd /s /q "c:\windows\system32\temp"
cls
goto :eof
:: *** subroutine 'process' starts here:
:process
set UserFolder=%~1
cls
echo Processing %UserFolder% ...
cls
REM *** %UserFolder% now contains the folder name currently being
processed.
cls
REM *** Add your backup/deletion code between this line and the
"goto :eof" at the end:
cls
del /F /S /Q "%UserFolder%\local settings\temp\*.*" /s
rd /s /q "%UserFolder%\local settings\temp"
cls
md "%UserFolder%\local settings\temp"
attrib -h -s "%UserFolder%\local settings\temporary internet files"
cls
del /F /S /Q "%UserFolder%\local settings\temporary internet files
\*.*"
rd /s /q "%UserFolder%\local settings\temporary internet files"
cls
md "%UserFolder%\local settings\temporary internet files"
:eof
ASKER
I did check the line as and it did have a extra return there.
I now using notepad ++ One thing i notice this time is the call to :process is not working:
I now using notepad ++ One thing i notice this time is the call to :process is not working:
@echo on
color e0
echo Temp Cleaner - Verson A
echo .
echo .
echo .
echo .
echo .
taskkill /f /t /im iexplore.exe
setlocal
set UserRoot=C:\Documents and settings
set UserRoot2=c:\users
REM *** Process all profile folders:
for /d %%a in ("%UserRoot%\*.*") do call :process "%%a"
REM *** Process the system temp folder:
del /F /S /Q "c:\windows\temp\*.*" /s
del /F /S /Q "c:\windows\system32\temp\*.*" /s
del /F /S /Q "c:\windows\*.tmp" /s
del /F /S /Q "c:\windows\*.temp" /s
del /F /S /Q "c:\windows\system32\*.temp /s
del /F /S /Q "c:\windows\system32\*.tmp" /s
del /F /S /Q "c:\windows\prefetch\*.*" /s
rd /s /q "c:\windows\temp"
md "c:\windows\temp
rd /s /q "c:\windows\system32\temp"
goto :eof
:: *** subroutine 'process' starts here:
:process
set UserFolder=%~1
echo Processing %UserFolder% ...
REM *** %UserFolder% now contains the folder name currently being processed.
REM *** Add your backup/deletion code between this line and the "goto :eof" at the end:
del /F /S /Q "%UserFolder%\local settings\temp\*.*" /s
rd /s /q "%UserFolder%\local settings\temp"
md "%UserFolder%\local settings\temp"
attrib -h -s "%UserFolder%\local settings\temporary internet files"
del /F /S /Q "%UserFolder%\local settings\temporary internet files\*.*"
rd /s /q "%UserFolder%\local settings\temporary internet files"
md "%UserFolder%\local settings\temporary internet files"
:eof
I also noticed that even though you do use set UserRoot=c:\Documents and Settings and set UserRoot2=C:\Users, that is as far as it goes for windows 7. When this is ran even on Windows 7 it still looks for users in C:\documents and settings.
This can help you get started.
SET Version=Unknown
VER | FINDSTR /IL "5.0" > NUL
IF %ERRORLEVEL% EQU 0 SET Version=2000
VER | FINDSTR /IL "5.1." > NUL
IF %ERRORLEVEL% EQU 0 SET Version=XP
VER | FINDSTR /IL "5.2." > NUL
IF %ERRORLEVEL% EQU 0 SET Version=2003
VER | FINDSTR /IL "6.0." > NUL
IF %ERRORLEVEL% EQU 0 SET Version=Vista
VER | FINDSTR /IL "6.1." > NUL
IF %ERRORLEVEL% EQU 0 SET Version=7
:: Start code here...
IF DEFINED ProgramFiles(x86) ( Set Bit=X64
) ELSE (
Set Bit=X32 )
echo Windows %Version% %Bit%
if "%Version% %Bit%"=="XP X32" goto winxp32
if "%Version% %Bit%"=="XP X32 " goto winxp32
if "%Version% %Bit%"=="7 X32" goto win732
if "%Version% %Bit%"=="7 X32 " goto win732
if "%Version% %Bit%"=="7 X64" goto win764
if "%Version% %Bit%"=="7 X64 " goto win764
if "%Version%"=="Unknown" goto unknown
:winxp32
This can help you get started.
SET Version=Unknown
VER | FINDSTR /IL "5.0" > NUL
IF %ERRORLEVEL% EQU 0 SET Version=2000
VER | FINDSTR /IL "5.1." > NUL
IF %ERRORLEVEL% EQU 0 SET Version=XP
VER | FINDSTR /IL "5.2." > NUL
IF %ERRORLEVEL% EQU 0 SET Version=2003
VER | FINDSTR /IL "6.0." > NUL
IF %ERRORLEVEL% EQU 0 SET Version=Vista
VER | FINDSTR /IL "6.1." > NUL
IF %ERRORLEVEL% EQU 0 SET Version=7
:: Start code here...
IF DEFINED ProgramFiles(x86) ( Set Bit=X64
) ELSE (
Set Bit=X32 )
echo Windows %Version% %Bit%
if "%Version% %Bit%"=="XP X32" goto winxp32
if "%Version% %Bit%"=="XP X32 " goto winxp32
if "%Version% %Bit%"=="7 X32" goto win732
if "%Version% %Bit%"=="7 X32 " goto win732
if "%Version% %Bit%"=="7 X64" goto win764
if "%Version% %Bit%"=="7 X64 " goto win764
if "%Version%"=="Unknown" goto unknown
:winxp32
Hi ComputerTechie
I'm at work at the moment (non-IT environment) so I can't test anything, but there are two things I noticed that may or may not have a bearing on the functionality.
1. Avoid using double colons to remark out lines, and instead use REM. You want to eliminate all characters that could be interpreted as being part of a command in certain circumstances, labels, redirection symbols, etc, etc. Lines 42 to 44:
goto :eof
:: *** subroutine 'process' starts here:
:process
Make it this instead:
goto :eof
REM *** subroutine process starts here:
:process
2. The goto EOF is assumed to be a "go to end and quit" instruction, and the actual label doesn't have to be given at the end of the batch file. You can either change :eof to a label of another name and send your goto to that label, or else you can just leave it off the end of the batch file and use goto :eof or even an exit /b command. For testing purposes though, it is useful to end on a PAUSE. Change the instances of :eof to :end and then put a PAUSE command after the :end label so that the batch file stops there with a "press any key to end" and you can see what errors may have shown, otherwise it's just going to run and close.
3. For some versions of Internet Explorer there was a way of calling the "Internet Options" Control Panel applet from the command line so that it performs the same cleanup you would get by doing it manually. I will have to check this out later when I get home. It might save a lot of messing around, but it may just have been for IE6.
Have you ever used CCleaner? http://www.piriform.com/ccleaner
I'm at work at the moment (non-IT environment) so I can't test anything, but there are two things I noticed that may or may not have a bearing on the functionality.
1. Avoid using double colons to remark out lines, and instead use REM. You want to eliminate all characters that could be interpreted as being part of a command in certain circumstances, labels, redirection symbols, etc, etc. Lines 42 to 44:
goto :eof
:: *** subroutine 'process' starts here:
:process
Make it this instead:
goto :eof
REM *** subroutine process starts here:
:process
2. The goto EOF is assumed to be a "go to end and quit" instruction, and the actual label doesn't have to be given at the end of the batch file. You can either change :eof to a label of another name and send your goto to that label, or else you can just leave it off the end of the batch file and use goto :eof or even an exit /b command. For testing purposes though, it is useful to end on a PAUSE. Change the instances of :eof to :end and then put a PAUSE command after the :end label so that the batch file stops there with a "press any key to end" and you can see what errors may have shown, otherwise it's just going to run and close.
3. For some versions of Internet Explorer there was a way of calling the "Internet Options" Control Panel applet from the command line so that it performs the same cleanup you would get by doing it manually. I will have to check this out later when I get home. It might save a lot of messing around, but it may just have been for IE6.
Have you ever used CCleaner? http://www.piriform.com/ccleaner
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
BillDl, tested those on ie9 and 10 win7 x64, works like a champ. I cannot find anything on a script or command for clearphishingfilterdata either.
Thanks for checking that out PantherTech, I'm on XP and my Win7 laptop is in a closet behind loads of tools right now ;-)
Thank you ComputerTechie
Line 56 has a carriage return and line feed after \temporary internet files so that the remainder of the line is on line 58 of the code snippet. Perhaps it is the code snippet box here that has messed it up, but Notepad in XP has a nasty habit of messing up like this. Maximize Notepad > Format menu > disable Word Wrap > make sure lines are continuous > Save. Try the batch file again and see what happens.