标题:有没有批处理高手,请指点下
只看楼主
tslltsll
Rank: 1
来 自:SH
等 级:新手上路
帖 子:5
专家分:0
注 册:2017-5-12
 问题点数:0 回复次数:1 
有没有批处理高手,请指点下
我的目标是自动清理用户电脑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
搜索更多相关主题的帖子: users Local Microsoft Temp del 
2017-06-28 15:26
tslltsll
Rank: 1
来 自:SH
等 级:新手上路
帖 子:5
专家分:0
注 册:2017-5-12
得分:0 

JAVA菜鸟
2017-06-28 15:30



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-479013-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.246320 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved