2012-06-29 44 views
0

基本上我需要刪除所有的臨時文件,並且我已經得到了以下腳本。由於所有位置都是硬編碼的,並且並非所有人都使用默認位置,所以我想知道是否有人可以用腳本來幫助我,腳本可以與當前腳本兼容,從當前每個配置文件中檢測所有「Temporary Internet Files」文件夾的位置並刪除不需要的。 解決方案將是一個很大的幫助。使用bat文件檢測「Temporary Internet Files」文件夾的位置並刪除它們

來源:http://www.expertsexchange.com/OS/Microsoft_Operating_Systems/Windows/2000/Q_20794666.html

CODE:


cls 
    SET SRC1=%SYSTEMDRIVE%\Documents and Settings 
    SET SRC2=Local Settings\Temporary Internet Files 
    SET SRC3=Local Settings\Temp 
    SET SRC4=Local Settings\History 
    SET SRC5=%SYSTEMROOT%\Temp 
    SET SRC6=Cookies 


    echo About to delete files from Internet Explorer "Temporary Internet files" 
    FOR /D %%X IN ("%SRC1%\*") DO FOR /D %%Y IN ("%%X\%SRC2%\*.*") DO RMDIR /S /Q "%%Y" 
    echo About to delete files from "Local settings\temp" 
    FOR /D %%X IN ("%SRC1%\*") DO FOR /D %%Y IN ("%%X\%SRC3%\*.*") DO RMDIR /S /Q "%%Y" 
    FOR /D %%X IN ("%SRC1%\*") DO FOR %%Y IN ("%%X\%SRC3%\*.*") DO DEL /F /S /Q "%%Y" 
    echo About to delete files from "Windows\Temp" 
    cd\  
    %systemdrive% 
    cd /d %SystemRoot%\temp 
    del /F /Q *.* 
    @echo Y|RD /S "" 
    @echo. 
    @echo. 
    echo About to delete files from "Local Settings\History" 
    FOR /D %%X IN ("%SRC1%\*") DO FOR %%Y IN ("%%X\%SRC4%\*.*") DO DEL /F /S /Q "%%Y" 

    FOR /D %%X IN ("%SRC1%\*") DO FOR %%Y IN ("%%X\%SRC4%\today*.*") DO DEL /F /S /Q "%%Y" 

    FOR /D %%X IN ("%SRC1%\*") DO FOR %%Y IN ("%%X\%SRC4%\*.*") DO DEL /F /S /Q "%%Y" 

    echo About to delete files from "%SYSTEMROOT%\Temp" 
    FOR /D %%X IN ("%SRC1%\*") DO FOR %%Y IN ("%%X\%SRC5%\*.*") DO DEL /F /S /Q "%%Y" 

    echo About to delete files from "Cookies" 
    FOR /D %%X IN ("%SRC1%\*") DO FOR %%Y IN ("%%X\%SRC6%\*.*") DO DEL /F /S /Q "%%Y" 

    @echo   Please review any errors if they exist 
    @echo. 
    @echo. 
+0

任何提示..任何人.. – user1491091

回答

1

嘗試下面的腳本...但我不知道用戶配置文件選擇...

del /q /s "c:\winnt\temp\*.*"  
del /q /s "c:\windows\temp\*.*"  
del /q /s "%USERPROFILE%\Local Settings\Temp\*.*"  
del /q /s "%USERPROFILE%\Local Settings\Temporary Internet Files\*.*"  
del /q /s "%USERPROFILE%\Cookies\*.*"  
del /q /s "%USERPROFILE%\Recent\*.*"  
Rmdir /q /s "%USERPROFILE%\Local Settings\Temporary Internet Files"  
Rmdir /q /s "%USERPROFILE%\Local Settings\Temp"  
Rmdir /q /s "%USERPROFILE%\Cookies\*.*"  
Rmdir /q /s "c:\winnt\Temp"  
Rmdir /q /s "c:\windows\Temp" 
md "%USERPROFILE%\Local Settings\Temporary Internet Files"  
md "%USERPROFILE%\Local Settings\Temp"  
md "%USERPROFILE%\Cookies"  
md "c:\winnt\Temp"  
md "c:\windows\Temp" 
相關問題