It is currently Sat Dec 16, 2017 6:12 pm
Post a new topicPost a reply Page 1 of 1   [ 5 posts ]
Author Message
PostPosted: Mon Mar 21, 2016 9:36 am 
Site Admin
User avatar

Joined: Thu Jan 19, 2012 2:45 pm
Posts: 2935
Location: Compton
Found this useful when I had to make space urgently on one of the Windows server 2008 R2 machines at work this morning. Hope it is useful to you:


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 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 The Thumbnail and Icon Caches
Delete Backed Up Files Made By Photo Gallery
Extending The Size of the Drive
Compress Files
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.



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

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\*.*" /a /s


Then to delete.

Close Internet 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

Then to see the new size.

dir "%userprofile%\AppData\Local\Microsoft\Windows\Temporary Internet Files\*.*" /a /s

Delete Files in the System Temp Folder

The system temp folder is only used when noone is logged in. It is rarely used but never 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 /a /s

To delete

del 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, 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 /a /s

Then to compact

sc stop wuauserv
sc stop bits
sc stop wsearch
for /r c:\ %A in (*.edb *.msmessagestore WebCacheV*.dat) do esentutl.exe /p "%A" /o
for /r c:\ %A in (*.edb *.msmessagestore WebCacheV*.dat) do esentutl.exe /d "%A"
sc start wsearch
sc start bits
sc start wuauserv


Then to see the new size and compare to the old size

dir c:\*.edb c:\*.msmessagestore c:\WebCacheV*.dat /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"

Then to delete some temporary files.

del c:\*.integ.raw c:\TEMPDFRG*.edb /s

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

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\*.*"

Supercharging Disk Cleanup

How Disk Cleanup works
Scheduling Disk Cleanup
Creating custom cleaners

C:\Users\David Candy>@echo.&@echo List of cleaners&@echo ================&FOR /F
"usebackq tokens=8 delims=\" %i IN (`reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Mic
rosoft\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

_________________
Image


Top
OfflineProfile
PostPosted: Mon Mar 21, 2016 9:41 am 
User avatar

Joined: Thu Jan 19, 2012 7:25 pm
Posts: 1059
Location: Gladstone
Nice post, but you could spend $79 on extra 2TB HDD. go go gadget.

_________________
Image
ImageImage


Top
OfflineProfile
PostPosted: Mon Mar 21, 2016 9:53 am 
Site Admin
User avatar

Joined: Thu Jan 19, 2012 2:45 pm
Posts: 2935
Location: Compton
Edited to segregate the contents.

And not everyone wants to go buy another hard disk just because they have a massive system restore cache or large amount of temp files :)

_________________
Image


Top
OfflineProfile
PostPosted: Mon Mar 21, 2016 11:45 am 
Site Admin

Joined: Thu Jan 19, 2012 6:21 pm
Posts: 970
awesome post mate... . 8-)

_________________
Image


Top
OfflineProfile
PostPosted: Mon Mar 21, 2016 5:14 pm 
User avatar

Joined: Sat Feb 18, 2012 10:03 am
Posts: 1264
Location: Adelaide
This will come in handy for those infamous mum and dad laptops

_________________
Image



Image


Top
OfflineProfile
Display posts from previous:  Sort by  
Post a new topicPost a reply Page 1 of 1   [ 5 posts ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Jump to:  

Powered by phpBB® Forum Software © phpBB Group
Code Black-Bird © 2011-2012 by FanFanLaTuFlippe