Windows 用于删除终端服务器上用户配置文件的Firefox缓存的批处理文件

Windows 用于删除终端服务器上用户配置文件的Firefox缓存的批处理文件,windows,batch-file,file-io,Windows,Batch File,File Io,我想运行一个批处理文件,删除终端服务器上所有用户配置文件的firefox缓存文件夹。与ICSweep非常相似,它为所有用户删除临时internet文件 Location: C:\users\ *username*\appdata\local\mozilla\firefox\profiles\ *random*.default\cache 问题是不同的用户名文件夹,firefox\profiles下的子文件夹名称包含“随机字符.default”,并且对于所有用户都不同 Location: C:\

我想运行一个批处理文件,删除终端服务器上所有用户配置文件的firefox缓存文件夹。与ICSweep非常相似,它为所有用户删除临时internet文件

Location: C:\users\ *username*\appdata\local\mozilla\firefox\profiles\ *random*.default\cache
问题是不同的用户名文件夹,firefox\profiles下的子文件夹名称包含“随机字符.default”,并且对于所有用户都不同

Location: C:\users\ *username*\appdata\local\mozilla\firefox\profiles\ *random*.default\cache
这可以通过批处理文件完成吗?或者我需要vb脚本之类的东西

如果可以做到这一点,我也会为谷歌Chrome缓存做到这一点

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

是的,这是可以做到的。它只需要一些简单的批处理递归。此脚本已完全准备好使用。准备删除缓存文件夹时,只需将
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:

:: 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
::隐藏命令
rem@回声关闭
setLocalEnableExtensions
::解析本地AppData子路径
调用:展开xAppData“%%LocalAppData:%UserProfile%%=%%”
设置“xFirefox=\mozilla\firefox\profiles”
设置“xChrome=\google\chrome\user data”
::从用户目录开始
pushd“%UserProfile%\…”
::循环浏览用户
对于(*)中的/D%%D,如果存在请执行“%%~fD%xAppData%”(
Firefox的rem检查
rem如果存在“%%~fD%xAppData%%xFirefox%”(
如果存在“%%~fD%xAppData%%xLocal%%xMozilla%%xFirefox%”(
rem pushd“%%~fD%xAppData%%xFirefox%”
pushd“%%~fD%xAppData%%xLocal%%xMozilla%%xFirefox%”
rem循环通过配置文件
对于(*)中的/D%%P,请执行以下操作(
如果存在“%%~fP\cache2”del/F/Q/S“%%~fP\cache2”
)
邻苯二胺
)
)
邻苯二胺
转到终点
::::::::::::::::::::::::::::::
:展开
如果不是“%~1”==”设置“%~1=%~2”
后藤:eof
:结束
端部
暂停

<代码> >在<代码> %AppDATA%\Mozilla \ Firefox的配置文件中,您没有考虑<代码> IsAs==0 。因为OP只提到了Firefox的配置文件文件夹。但是,我已经添加了使用PrruliSini文件所需的修改。只需注意删除当前登录O的缓存可能不是一个好主意。n运行FireFox的用户,因此我建议使用quser命令查看谁登录,但我不确定是否可以使用CMD搜索字符串之类的内容,因此最好使用VBS或AutoIt。也可能有些用户名与其profilefolder名称不同。。。