查看: 9822|回复: 24
收起左侧

[技巧] 微软论坛找到的,相当详细的,清理C盘空间的方法

[复制链接]
ELOHIM
发表于 2015-4-28 21:51:12 | 显示全部楼层 |阅读模式
本帖最后由 ELOHIM 于 2015-4-29 09:41 编辑

[mw_shl_code=shell,true]Freeing up Disk Space
Last Updated 18-1-2014
Contents
•To see how much space you have used and free
•To see where files are taking up space
•Disk Cleanup
•System Restore
•Repair the Recycle Bin
•Repair Temporary Internet Files
•Delete Files in the System and Service Profiles Temp Folder  
•Check Size of Swap File
•Turn Off Hibernation
•Compact the Various Databases Windows Uses
•Remove files updated by Service Packs
•Relocate Your Documents
•Delete Backed Up Files Made By Photo Gallery
•Extending The Size of the Drive
•Compress Files
•Turn off Low Disk Space Warnings
•Supercharging Disk Cleanup

To see how much space you have used and free
Start - All Programs - Accessories - Right click Command Prompt and choose Run As Administrator. Type (or copy and paste by right clicking in the Command Prompt window and choosing Paste).
For the system drive
wmic volume where (DriveLetter='%systemdrive%') get Caption, Capacity, freespace /format:list
For all drives
wmic volume get Caption, Capacity, freespace /format:table
If you want to store this info on your desktop
wmic /append:"%userprofile%\desktop\Free Disk Space Report.html" volume get Caption, Capacity, freespace /format:htable
To open double click Free Disk Space Report.html on your desktop or type
start "" "%userprofile%\desktop\Free Disk Space Report.html"
Then come back here after cleaning and repeat these commands to see the difference.
If for some reason the wmic command doesn't work use these two commands. Both take a long time.
defrag %systemdrive% -a
or
dir %systemdrive%\*.* /a /s
To see where files are taking up space
This will list the number of files and size for folders on your drive. Each command does a subset so you can manage it better.
  
Start - All Programs - Accessories - Right click Command Prompt and choose Run As Administrator. Type (or copy and paste by right clicking in the Command Prompt window and choosing Paste).

Then configure the command prompt. Right click the Command Prompt's titlebar - Properties - Layout tab - and enter 1000 for Screen Buffer Size Height and 43 (or 50) for Window Size Height. Change the Color (Color tab) and Font (Font tab) if you want.
To see size of folders in Documents, excluding music, video, or pictures folders.
for /f "skip=2 tokens=3" %A in ('Reg query "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" /v "Personal"') do set doc=%A
for /f "usebackq tokens=2* delims= " %i IN (`dir "%doc%" /a /s ^|findstr /i /v "\/"^|findstr /l /v "Pictures Music Video"`) DO @echo %j&echo.
To see size of folders in Music.
for /f "skip=2 tokens=4" %A in ('Reg query "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" /v "My Music"') do set Doc=%A
for /f "usebackq tokens=2* delims= " %i IN (`dir "%doc%" /a /s ^|findstr /i /v "\/"`) DO @echo %j&echo.
To see size of folders in Pictures.
for /f "skip=2 tokens=4" %A in ('Reg query "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" /v "My Pictures"') do set Doc=%A
for /f "usebackq tokens=2* delims= " %i IN (`dir "%doc%" /a /s ^|findstr /i /v "\/"`) DO @echo %j&echo.
To see size of folders in Video.
for /f "skip=2 tokens=4" %A in ('Reg query "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" /v "My Video"') do set Doc=%A
for /f "usebackq tokens=2* delims= " %i IN (`dir "%doc%" /a /s ^|findstr /i /v "\/"`) DO @echo %j&echo.
To see size of folders on the Desktop.
for /f "skip=2 tokens=3" %A in ('Reg query "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" /v "Desktop"') do set doc=%A
for /f "usebackq tokens=2* delims= " %i IN (`dir "%doc%" /a /s ^|findstr /i /v "\/"`) DO @echo %j&echo.
  
To see size of folders the Windows folder.
for /f "usebackq tokens=2* delims= " %i IN (`dir "%windir%" /a /s ^|findstr /i /v "\/"`) DO @echo %j&echo.
To see size of folders the Program Files folder.
for /f "usebackq tokens=2* delims= " %i IN (`dir "%ProgramFiles%" /a /s ^|findstr /i /v "\/"`) DO @echo %j&echo.

Disk Cleanup
The normal way to run Disk Cleanup is to right click the drive in My Computer (Start menu - Computer), then Properties - General tab - Disk Cleanup button.

Another way is Start menu - All Programs - Accessories - System Tools - Disk Cleanup.
Disk Cleanup can be started from the command line.
Start - All Programs - Accessories - Right click Command Prompt and choose Run As Administrator. Type (or copy and paste by right clicking in the Command Prompt window and choosing Paste).
To do your main drive.
cleanmgr %systemdrive%
To choose which drive to do.
cleanmgr
See the last section of this note to see how to supercharge Disk Cleanup.
System Restore

In Disk Cleanup above also see the More Options tab. You can delete all but the last System Restore point and see if that is taking up space.
System Restore uses 15% of the disk space normally. To change click Start - All Programs - Accessories - Right click Command Prompt and choose Run As Administrator. Type Regedit and navigate to
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SystemRestore\cfg
and double click DiskPercent and click Decimal and change the value to the percentage you want,
You can change it at the command prompt.
Start - All Programs - Accessories - Right click Command Prompt and choose Run As Administrator. Type (or copy and paste by right clicking in the Command Prompt window and choosing Paste).
To see size of System Restore folder.
You don't normally have access to this folder. You need to take ownership, give administrators permission, then query the size.
takeown /f "%systemdrive%\System Volume Information" /a /r /d y  
icacls "%systemdrive%\System Volume Information" /grant Administrators:f /t /c /q
dir "%systemdrive%\System Volume Information" /a /s
To see current percentage
reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SystemRestore\cfg" /v DiskPercent
It's hexadecimal. Numbers are 0-9 then a-f. So 0xf is 15. 0x5 is 5, 0x9 is 9, 0xa is 10, 0x14 is 20.
To set to a different value.
You can use decimal values to set it. This sets it to 10% (bolded in the example and the last item on the line).
reg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SystemRestore\cfg" /v DiskPercent /t REG_DWORD /f /d 10
To repair the System Restore folder delete it and restart System Restore.
  
sc stop vss
takeown /f "%systemdrive%\System Volume Information" /a /r /d y  
icacls "%systemdrive%\System Volume Information" /grant Administrators:f /t /c /q
rd "%systemdrive%\System Volume Information" /q /s
sc start vss
Repair the Recycle Bin
Sometimes files get lost in the recycle bin. Delete the storage folders. It will be automatically recreated next time you delete a file or open the Recycle Bin. It will delete the Recycle Bin, and files it contains, for all users.
Empty the recycle bin.
Start - All Programs - Accessories - Right click Command Prompt and choose Run As Administrator. Type (or copy and paste by right clicking in the Command Prompt window and choosing Paste).
To see the size of files in the recycle bin
It should have one or no files in it if working. There should be a dir (folder) per user.
dir %systemdrive%\$RECYCLE.BIN\*.* /a /s
To reset the recycle bin
rd %systemdrive%\$RECYCLE.BIN /s /q
Repair Temporary Internet Files
Sometimes files get lost in the temporary internet files folder. Delete the files. It will be automatically recreated next time you download it. It will delete for the current user only.
Start - All Programs - Accessories - Right click Command Prompt and choose Run As Administrator. Type (or copy and paste by right clicking in the Command Prompt window and choosing Paste).
To see the size of files an empty temporary internet files folder
RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 8
dir "%userprofile%\AppData\Local\Microsoft\Windows\Temporary Internet Files\*.*" "%userprofile%\AppData\Local\Microsoft\Internet Explorer\DOMStore\*.*" /a /s

Then to delete.
Close Internet Explorer and Explorer first. Some files may not delete at this time, they will be able to be deleted later.
del "%userprofile%\AppData\Local\Microsoft\Windows\Temporary Internet Files" /s /q
also the DOM store, similar to TIF.
del "%userprofile%\AppData\Local\Microsoft\Internet Explorer\DOMStore" /s /q
Then to see the new size.
dir "%userprofile%\AppData\Local\Microsoft\Windows\Temporary Internet Files\*.*" "%userprofile%\AppData\Local\Microsoft\Internet Explorer\DOMStore\*.*" /a /s
To see the size of the cache type the following
Start - All Programs - Accessories - Right click Command Prompt and choose Run As Administrator. Type (or copy and paste by right clicking in the Command Prompt window and choosing Paste).
Reg query "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\5.0\Cache\Content" /v CacheLimit
Use calculator to convert from hex to decimal. Start Calculator (Start - All Programs - Accessories - Calculator) and choose View menu - Scientific, then View menu - Hex. Enter the value returned above. Then View menu -  Decimal. To convert to windows units divide by 1024 for kilobytes, divide again by 1024 for Megabytes.
Set between 50 MB and 250 MB. You can use decimal here. The unit is in kilobytes. The below is 250 megabytes (250,000 x 1024 bytes)
Reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\5.0\Cache\Content" /v CacheLimit /t Reg_DWord /d 250000 /f
  
Delete Files in the System and Service Profiles Temp Folder
The system temp folder is only used when noone is logged in. It is rarely used but never cleaned. Certain services have their own temp folder that is also not cleaned.
Start - All Programs - Accessories - Right click Command Prompt and choose Run As Administrator. Type (or copy and paste by right clicking in the Command Prompt window and choosing Paste).
To list
dir c:\windows\temp C:\Windows\ServiceProfiles\NetworkService\AppData\Local\Temp C:\Windows\ServiceProfiles\LocalService\AppData\Local\Temp /a /s
To delete
del  C:\Windows\ServiceProfiles\NetworkService\AppData\Local\Temp\*.* C:\Windows\ServiceProfiles\LocalService\AppData\Local\Temp\*.* c:\windows\temp\*.* /s /f /q
Check Size of Swap File
   
As a general rule you want your swap file a little bigger than the amount of memory you have. It grows automatically but doesn't shrink automatically. If using memory hungery programs like video editing it should be bigger. If too big you can shrink it and if pressed for space can be moved to another drive.
Start - All Programs - Accessories - Right click Command Prompt and choose Run As Administrator. Type (or copy and paste by right clicking in the Command Prompt window and choosing Paste).
To see what your usage has been
wmic pagefile get /format:list
To see the file size on disk
dir c:\pagefile.sys /a
To change size or change drive see Change the size of virtual memory in Start - Help and Support.

Turn Off Hibernation
The hiberation file is the same size of installed memory. If not hibernating the computer turn it off and save plenty of disk space.
Start - All Programs - Accessories - Right click Command Prompt and choose Run As Administrator. Type (or copy and paste by right clicking in the Command Prompt window and choosing Paste).
To see if it's on
If on the file will be found. If off the file won't be there.
dir %systemdrive%\hiberfil.sys /a
To turn off
powercfg -h off
To turn back on again
powercfg -h on

Compact the Various Databases Windows Uses
You can compact the various databases Windows uses. These are Windows Update, Windows Search, Security Certificates, Windows Mail, Windows Contacts, Windows Calandar, some Windows Live apps, and Internet Explorer ver 10.
Close Windows Mail and Internet Explorer. Wait a minute for Internet Explorer to release it's file locks.
To see how much space it taking up type what's below and note the total size (because it will scroll away).
Start - All Programs - Accessories - Right click Command Prompt and choose Run As Administrator. Type (or copy and paste by right clicking in the Command Prompt window and choosing Paste).
dir c:\*.edb c:\*.msmessagestore c:\WebCacheV*.dat c:\catdb /a /s
Then to compact
sc stop wuauserv
sc stop bits
sc stop wsearch
sc stop cryptsvc
for /r c:\ %A in (*.edb *.msmessagestore WebCacheV*.dat catdb*.) do esentutl.exe /p "%A" /o
for /r c:\ %A in (*.edb *.msmessagestore WebCacheV*.dat catdb*.) do esentutl.exe /d "%A"
sc start cryptsvc
sc start wsearch
sc start bits
sc start wuauserv
Then to delete some temporary files.
del c:\*.integ.raw c:\TEMPDFRG*.edb /s
Then to see the new size and compare to the old size
dir c:\*.edb c:\*.msmessagestore c:\WebCacheV*.dat c:\catdb /a /s
If a program has a file open you can use this procedure to find which program.
openfiles /local on
Reboot
openfiles /query /v|findstr /i "WebCacheV[0-9]*\.dat \.edb \.msmessagestore catdb"

Remove files updated by Service Packs
To see how much space it taking up type what's below and note the total size (because it will scroll away). Also note that the total is higher than it actually is.
This will remove the ability to uninstall the service packs.
Depending on the service pack Windows was supplied with you may have both, one, or neither of these two files.
Start - All Programs - Accessories - Right click Command Prompt and choose Run As Administrator. Type (or copy and paste by right clicking in the Command Prompt window and choosing Paste).
dir c:\Windows\WinSxS /a /s
Then type
VSP1CLN.exe
COMPCLN.exe
Then to see the new size and compare to the old size
dir c:\windows\WinSxS /a /s
Relocate Your Documents
If you have another drive you can move the documents folder to it.
Right click your Documents (or Pictures, Videos, Contacts, Desktop, etc) folder - Properties - Location tab - Move.
Delete The Thumbnail and Icon Caches
These files may contain thumbnails or icons of long ago deleted files. The files will be recreated as needed.
Start - All Programs - Accessories - Right click Command Prompt and choose Run As Administrator. Type (or copy and paste by right clicking in the Command Prompt window and choosing Paste). The desktop and Start menu will briefly disappear.
To see size
dir "%userprofile%\AppData\Local\*.db" "%userprofile%\AppData\Local\Microsoft\Windows\Explorer\*.db" /a
then to delete
taskkill /im explorer.exe /f
attrib -r -s -h "%userprofile%\AppData\Local\*.db"
attrib -r -s -h "%userprofile%\AppData\Local\Microsoft\Windows\Explorer\*.db"
del "%userprofile%\AppData\Local\*.db"
del "%userprofile%\AppData\Local\Microsoft\Windows\Explorer\*.db"
explorer
to check the new size
dir "%userprofile%\AppData\Local\*.db" "%userprofile%\AppData\Local\Microsoft\Windows\Explorer\*.db" /a
  
Delete Backed Up Files Made By Photo Gallery
Windows Photo Gallery makes a copy of any file you change. Click Start - All Programs - Accessories - Run (or press Winkey + R). Type
Shell:original images
Delete ones you don't want.
Extending The Size of the Drive
If all the space on the disk hasn't all been used it may be possible to extend your drive.
Start - All Programs - Accessories - Right click Command Prompt and choose Run As Administrator. Type (or copy and paste by right clicking in the Command Prompt window and choosing Paste).
diskpart
then type
select volume c:
Then type to see size
list volume
then (it will work if possible or won't if not possible)
extend
then type to see the new size
list volume
then to exit type
exit
If you want advice on extending the partition type the following and paste back the output
diskpart
list disk
list volume
select disk 0
list partition
select disk 1
list partition
exit
To copy the text output right click the window - Mark then select the text and press Enter.

Compress Files
There are two ways to compress files in windows. Zip files and the inbuilt file compression. This is about the inbuilt file compression. Type zip in Start - Help and Support for more info on zipping.
Photos, music, and video are already compressed. They may get larger if Windows tries to compress them any further. Also usually a bad idea to compress system files.
If you have document or spreadsheet files they can be compressed very well. If you have folders of setup files they may also be good candidates. Web  pages also make good candidates.
In Windows Explorer blue filenames means Compressed (this is file system compression not Compressed folders aka zip files). Green filenames means Encrypted.
To turn off coloured filenames, in Explorer - Tools menu (Alt + T) - View tab, and then clear the Show encrypted or compressed NTFS files in color check box.
Windows compression, encryption, and security work mostly by apply attributes to a folder, and files in the folder inherit from the folder.
If you have any folders suitable for compression find them in Explorer, right click them - Properties - General tab - Advanced button - Compress contents to save disk space. Choose to apply to all files and folders when asked.
To use a command line to compress the files in the Favorites folder.
Start - All Programs - Accessories - Right click Command Prompt and choose Run As Administrator. Type (or copy and paste by right clicking in the Command Prompt window and choosing Paste).
compact /c /s:"%userprofile%\Favorites" *.*
To set favourites to compress future files added
compact /c /s:"%userprofile%\Favorites"
To view compression details of the Favorites folder
compact "%userprofile%\Favorites\*.*"
  
Turn off Low Disk Space Warnings
To turn off the feature to show low disk space warnings.
Start - All Programs - Accessories - Right click Command Prompt and choose Run As Administrator. Type (or copy and paste by right clicking in the Command Prompt window and choosing Paste).
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer" /v "NoLowDiskSpaceChecks" /t REG_DWORD /d 1 /f
gpupdate /force

Supercharging Disk Cleanup
•How Disk Cleanup works
•Scheduling Disk Cleanup
•Creating custom cleaners
To see a list of Disk Cleanup cleaners.
Start - All Programs - Accessories - Right click Command Prompt and choose Run As Administrator. Type (or copy and paste by right clicking in the Command Prompt window and choosing Paste).
@echo.&@echo List of cleaners&@echo ================&FOR /F  "usebackq tokens=8 delims=\" %i IN (`reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches"`) DO @echo %i
List of cleaners
================
Active Setup Temp Folders
Content Indexer Cleaner
Downloaded Program Files
Hibernation File
Internet Cache Files
Memory Dump Files
Microsoft_Event_Reporting_2.0_Temp_Files
Offline Pages Files
Old ChkDsk Files
Previous Installations
Recycle Bin
Setup Log Files
System error memory dump files
System error minidump files
Temporary Files
Temporary Setup Files
Temporary Sync Files
Thumbnail Cache
Upgrade Discarded Files
Windows Error Reporting Archive Files
Windows Error Reporting Queue Files
Windows Error Reporting System Archive Files
Windows Error Reporting System Queue Files
WLX Thumbnail Cache
[/mw_shl_code]
原文链接:http://answers.microsoft.com/en- ... c-bfa2-269216767263
Kukon
发表于 2015-4-28 22:33:25 | 显示全部楼层
感谢分享

PS:把空行删了。
ELOHIM
 楼主| 发表于 2015-4-28 23:00:09 | 显示全部楼层
天岛男孩 发表于 2015-4-28 22:33
感谢分享

PS:把空行删了。


哈,被你发现了。。
卡饭还会自动换行,所以。。一会儿编辑一下。
skylinext
发表于 2015-4-28 23:10:46 | 显示全部楼层
编辑成批处理吗
ELOHIM
 楼主| 发表于 2015-4-28 23:13:00 | 显示全部楼层
本帖最后由 ELOHIM 于 2015-4-28 23:28 编辑


各取所需吧。。
里面的介绍很详细。
系统环境也不同,所以,需要清理哪块就用哪块。
批处理更加灵活,当然是好事,懒得弄了。。
拿来主义。
chngd
发表于 2015-4-29 01:05:02 来自手机 | 显示全部楼层
看不懂…~…~~
小河偶读
发表于 2015-4-29 10:31:20 | 显示全部楼层
看不懂…~…~~
珊瑚之恋
发表于 2015-4-29 10:47:25 | 显示全部楼层
路过支持。。。。。
zeseler
发表于 2015-4-29 10:57:42 | 显示全部楼层
确实很不错。。喜欢
东骧神骏
发表于 2015-5-16 13:26:11 | 显示全部楼层
英文真的看不懂啊~~~~
您需要登录后才可以回帖 登录 | 快速注册

本版积分规则

手机版|杀毒软件|软件论坛| 卡饭论坛

Copyright © KaFan  KaFan.cn All Rights Reserved.

Powered by Discuz! X3.4( 沪ICP备2020031077号-2 ) GMT+8, 2024-11-24 15:35 , Processed in 0.134103 second(s), 16 queries .

卡饭网所发布的一切软件、样本、工具、文章等仅限用于学习和研究,不得将上述内容用于商业或者其他非法用途,否则产生的一切后果自负,本站信息来自网络,版权争议问题与本站无关,您必须在下载后的24小时之内从您的电脑中彻底删除上述信息,如有问题请通过邮件与我们联系。

快速回复 客服 返回顶部 返回列表