我目前有一个批处理文件,用于从我的域名中删除2个文件夹,如下所示。
IF EXIST "C:\Documents and Settings\%Username%\Application Data\Mozilla" (
rmdir "C:\Documents and Settings\%Username%\Application Data\Mozilla" /s /q
)
IF EXIST "C:\Documents and Settings\%Username%\Application Data\Microsoft\CryptnetUrlCache" (
rmdir "C:\Documents and Settings\%Username%\Application Data\Microsoft\CryptnetUrlCache" /s /q
)
但是自从找到这个批处理文件的成功后,我们决定在服务器上的所有用户文件上实现它。 \%Username%\
部分只会删除当前登录的用户?我希望它能从每个配置文件中删除它。
E:\Profiles\
是我们存储所有用户个人资料的地方。
答案 0 :(得分:0)
你可以做一点“Gambiarra”(Gambiarra是一种修复,在巴西,我们称之为Gambiarra或Gambis)
@echo off
pushd %userprofile%
cd..
dir /b > "%~dp0\users.txt"
popd
For /F "delims=*" %%a in (users.txt) do (
set invalid=0
CALL:PROCESS "%%a")
del users.txt
echo/Finish with error level %error%
pause>nul
:PROCESS
For %%b in (Public UpdatusUser) do (CALL:EXCUSR "%%b" "%~1")
if %invalid% EQU 1 (exit/b)
if /i "%~1" == "All Users" (exit/b)
if "%~x1" NEQ "" (exit/b)
set "user=%~1"
IF EXIST "C:\Documents and Settings\%User%\Application Data\Mozilla" (
rmdir "C:\Documents and Settings\%User%\Application Data\Mozilla" /s /q
)
IF EXIST "C:\Documents and Settings\%User%\Application Data\Microsoft\CryptnetUrlCache" (
rmdir "C:\Documents and Settings\%User%\Application Data\Microsoft\CryptnetUrlCache" /s /q
)
echo/User %user% complete
set error=%errorlevel%
exit/b
:EXCUSR
if "%~1" == "%~2" set invalid=1&exit/b
net user %~2 1>nul 2>nul || set invalid=1&exit/b
exit/b
我希望此代码可以帮助您
答案 1 :(得分:0)
您可以使用Active Setup。只需添加到bat文件的Active Setup执行(使用正确的环境变量来访问userprofile):)祝你好运)