有没有批处理高手,请指点下
我的目标是自动清理用户电脑C盘指定的目录临时文件及文件夹和排除当前活动中的用户文件夹。那位大侠指点下,非常感谢!本程序是别人写的,我不懂IF语句,理论上只要加一个判断IF %%i=ECHO %USERNAME% 但不知道具体怎么做。
@echo off
cd /d c:\users
dir /b >>c:\profile_list.txt
for /F %%i in (c:\profile_list.txt) DO (
if not %%i==Public (
takeown /F c:\users\%%i\AppData\Roaming\Teamcenter /A /R /D Y
cacls c:\users\%%i\AppData\Roaming\Teamcenter /E /c /G everyone:f
takeown /F c:\users\%%i\AppData\Local\CATCACHE /A /R /D Y
cacls c:\users\%%i\AppData\Local\CATCACHE /E /c /G everyone:f
takeown /F c:\users\%%i\Teamcenter /A /R /D Y
cacls c:\users\%%i\Teamcenter /E /c /G everyone:f
takeown /F c:\users\%%i\AppData\Roaming\Teamcenter\FCCCache\%%i /A /R /D Y
cacls c:\users\%%i\AppData\Roaming\Teamcenter\FCCCache\%%i /T /E /c /G everyone:f
takeown /F c:\users\%%i\AppData\LocalLow\Sun /A /R /D Y
cacls c:\users\%%i\AppData\LocalLow\Sun /E /c /G everyone:f
takeown /F c:\users\%%i\AppData\Local\DassaultSystemes /A /R /D Y
cacls c:\users\%%i\AppData\Local\DassaultSystemes /E /c /G everyone:f
takeown /F c:\users\%%i\AppData\Local\Microsoft /A /R /D Y
cacls c:\users\%%i\AppData\Local\Microsoft /E /c /G everyone:f
takeown /F c:\users\%%i\AppData\Local\Temp /A /R /D Y
cacls c:\users\%%i\AppData\Local\Temp /E /c /G everyone:f
takeown /F c:\Users\%%i\Download /A /R /D Y
cacls c:\Users\%%i\Download /E /c /G everyone:f
takeown /F C:\Users\%%i\Documents /A /R /D Y
cacls C:\Users\%%i\Documents /E /c /G everyone:f
takeown /F C:\Users\%%i\Desktop /A /R /D Y
cacls C:\Users\%%i\Desktop /E /c /G everyone:f
del c:\users\%%i\Desktop\* /F /S /Q
del c:\users\%%i\Teamcenter\* /F /S /Q
del c:\users\%%i\AppData\Roaming\Teamcenter\* /F /S /Q
del c:\users\%%i\AppData\Local\CATCACHE\* /F /S /Q
del c:\users\%%i\AppData\Roaming\Teamcenter\FCCCache\%%i\* /F /S /Q
del c:\users\%%i\AppData\LocalLow\Sun\* /F /S /Q
del c:\users\%%i\AppData\Local\DassaultSystemes\* /F /S /Q
del c:\users\%%i\AppData\Local\Microsoft\* /F /S /Q
del c:\users\%%i\AppData\Local\Temp\* /F /S /Q
del C:\Users\%%i\Documents\* /F /S /Q
del c:\Users\%%i\Download\* /F /S /Q
rd c:\users\%%i\Teamcenter\ /S /Q
rd c:\users\%%i\AppData\Roaming\Teamcenter\ /S /Q
rd c:\users\%%i\AppData\Local\CATCACHE\ /S /Q
rd c:\users\%%i\AppData\Roaming\Teamcenter\FCCCache\%%i\ /S /Q
rd c:\users\%%i\AppData\LocalLow\Sun\ /S /Q
rd c:\users\%%i\AppData\Local\DassaultSystemes\ /S /Q
rd c:\users\%%i\AppData\Local\Microsoft\ /S /Q
)else echo JieShou
)
del c:\$Recycle.Bin\* /F /S /Q
del c:\temp\* /F /S /Q
del /f /s /q C:\Temp\del_all_profiles.bat
del c:\profile_list.txt
pause