Rob van der Woude's Scripting Pages
Powered by GeSHi

Source code for ffxcache.bat

(view source code of ffxcache.bat as plain text)

  1. @ECHO OFF
  2. IF NOT "%OS%"=="Windows_NT" GOTO Syntax
  3. SETLOCAL ENABLEDELAYEDEXPANSION
  4. IF NOT  "%~1"==""           GOTO Syntax
  5.  
  6. TASKLIST.EXE >NUL 2>&1
  7. IF NOT ERRORLEVEL 1 (
  8. 	TASKLIST.EXE /FI "imagename eq firefox.exe" 2>NUL | FIND /I "firefox.exe" >NUL
  9. 	IF NOT ERRORLEVEL 1 (
  10. 		ECHO.
  11. 		ECHO Firefox is still running, unable to clear the cache.
  12. 		GOTO Syntax
  13. 	)
  14. )
  15.  
  16. SET Profile=
  17. PUSHD "%UserProfile%\Application Data\Mozilla\Firefox"
  18. IF NOT ERRORLEVEL 1 FOR /F "tokens=2 delims==" %%A IN ('TYPE profiles.ini ^| FINDSTR.EXE /R /B /I /C:"Path="') DO SET Profile=%%~nxA
  19. POPD
  20. IF NOT "%Profile%"=="" (
  21. 	FOR %%A IN (Cache Cache.Trash OfflineCache) DO (
  22. 		PUSHD "%UserProfile%\Local Settings\Application Data\Mozilla\Firefox\Profiles\%Profile%\%%~A" 2>NUL
  23. 		IF /I "!CD!"=="%UserProfile%\Local Settings\Application Data\Mozilla\Firefox\Profiles\%Profile%\%%~A" RD /Q /S "%UserProfile%\Local Settings\Application Data\Mozilla\Firefox\Profiles\%Profile%\%%~A" 2>NUL
  24. 		POPD
  25. 	)
  26. ) ELSE (
  27. 	ECHO.
  28. 	ECHO Profile directory not found or no access.
  29. 	GOTO Syntax
  30. )
  31. ENDLOCAL
  32. GOTO:EOF
  33.  
  34.  
  35. :Syntax
  36. ECHO.
  37. ECHO FfxCache.bat,  Version 1.10 for Windows NT 4 and later
  38. ECHO Flush the Firefox cache directory in your own profile
  39. ECHO.
  40. ECHO Usage:  FFXCACHE
  41. ECHO.
  42. ECHO Note:   This batch file won't be able to clear the cache when Firefox is
  43. ECHO         running. In Windows XP and later, the batch file will check if
  44. ECHO         Firefox is running and abort if so, in Windows NT 4 and 2000 the
  45. ECHO         batch file will display an error message for each cache file in use.
  46. ECHO.
  47. ECHO Written by Rob van der Woude
  48. ECHO http://www.robvanderwoude.com
  49.  
  50. IF "%OS%"=="Windows_NT" ENDLOCAL
  51.  

page last uploaded: 2016-12-15, 11:20