2

我想运行一个批处理文件,删除终端服务器上所有用户配置文件的 firefox 缓存文件夹。就像 ICSweep 删除所有用户的临时 Internet 文件一样。

Location: C:\users\ *username*\appdata\local\mozilla\firefox\profiles\ *random*.default\cache

问题是不同的用户名文件夹,并且 firefox\profiles 下的子文件夹的名称包含“随机字符.default”,并且对于所有用户都不同。

这可以用批处理文件完成吗?还是我需要类似 vb 脚本的东西?

如果可以这样做,我也会为 Google Chrome 缓存执行此操作

C:\users\ *username*\appdata\local\google\chrome\user data\default\cache
4

2 回答 2

2

是的,这是可以做到的。它只需要一些简单的批量递归。该脚本已完全可以使用。准备好删除缓存文件夹时,只需将echo命令替换为命令即可。del

:: Hide Commands
@echo off
setlocal EnableExtensions

:: Parse the Local AppData sub path
call :Expand xAppData "%%LocalAppData:%UserProfile%=%%"

set "xFirefox=\mozilla\firefox\profiles"
set "xChrome=\google\chrome\user data"

:: Start at the User directory
pushd "%UserProfile%\.."

:: Loop through the Users
for /D %%D in (*) do if exist "%%~fD%xAppData%" (
    rem Check for Firefox
    if exist "%%~fD%xAppData%%xFirefox%" (
        pushd "%%~fD%xAppData%%xFirefox%"

        rem Loop through the Profiles
        for /D %%P in (*) do (
            if exist "%%~fP\cache" echo "%%~fP\cache"
        )
        popd
    )

    rem Check for Chrome
    if exist "%%~fD%xAppData%%xChrome%" (
        pushd "%%~fD%xAppData%%xChrome%"

        rem Loop through the Profiles
        for /D %%P in (*) do (
            if exist "%%~fP\cache" echo "%%~fP\cache"
        )
        popd
    )
)
popd
goto End


::::::::::::::::::::::::::::::
:Expand <Variable> <Value>
if not "%~1"=="" set "%~1=%~2"
goto :eof


:End
endlocal
pause

更新评论

要使用 Firefox profiles.ini 文件,请将上面的检查 firefox 部分替换为该文件。

rem Check for Firefox INI
if exist "%%~fD%xAppData%%xFirefox%\profiles.ini" (
    pushd "%%~fD%xAppData%%xFirefox%\"

    rem Loop through the Profiles
    for /f "tokens=1,* delims==" %%L in (profiles.ini) do (
        if /i "%%~L"=="Path" if exist "%%~fM\cache\" echo "%%~fM\cache"
    )
    popd
)
于 2012-12-28T16:33:32.700 回答
0

上面脚本的更新版本,只有 Firefox :

:: Hide Commands
rem @echo off
setlocal EnableExtensions

:: Parse the Local AppData sub path
call :Expand xAppData "%%LocalAppData:%UserProfile%=%%"

set "xFirefox=\mozilla\firefox\profiles"
set "xChrome=\google\chrome\user data"

:: Start at the User directory
pushd "%UserProfile%\.."

:: Loop through the Users
for /D %%D in (*) do if exist "%%~fD%xAppData%" (
    rem Check for Firefox
    rem if exist "%%~fD%xAppData%%xFirefox%" (
    if exist  "%%~fD%xAppData%%xLocal%%xMozilla%%xFirefox%" (
        rem pushd "%%~fD%xAppData%%xFirefox%"
        pushd "%%~fD%xAppData%%xLocal%%xMozilla%%xFirefox%"

        rem Loop through the Profiles
        for /D %%P in (*) do (
            if exist "%%~fP\cache2" del /F /Q /S "%%~fP\cache2"
        )
        popd
    )
)
popd
goto End


::::::::::::::::::::::::::::::
:Expand <Variable> <Value>
if not "%~1"=="" set "%~1=%~2"
goto :eof


:End
endlocal
pause
于 2018-10-01T15:38:28.900 回答