download.png

Hello

Today I’ll hand over several useful scripts  & command lines regarding hard-disk space cleaning

Possible scenario: Not disturbing the user while is doing its job we may manage to clean some temporary files

Not disturbing nor bothering  the user while is doing its job could be done raising a ms-dos console connection suck PSadmin(psexec) tough PowerShell consoles remote

 

  1. CMD – Knowing how much space is free in GB throught msdos mini script

for /f “tokens=1-3” %a in (‘WMIC LOGICALDISK GET FreeSpace^,Name^,Size ^|FINDSTR /I /V “Name”‘) do @echo wsh.echo “%b” ^& ” free=” ^& FormatNumber^(cdbl^(%a^)/1024/1024/1024, 2^)^& ” GiB”^& ” size=” ^& FormatNumber^(cdbl^(%c^)/1024/1024/1024, 2^)^& ” GiB” > %temp%\tmp.vbs & @if not “%c”==”” @echo( & @cscript //nologo %temp%\tmp.vbs & del %temp%\tmp.vbs

will output something like this

2017-06-29 19_40_22-Select Command Prompt.png

2. CMD- Searching for huge files 

forfiles /p c:\ /s /m *.* /c “cmd /c if @fsize gtr 100000000 echo @file @path”

will output huge files, size is in bytes and can be changed, locate the garbage ones and delete it

3. Deleting hyberfiles.sys

Hiberfil.sys is a file the system creates for the computer to enter hibernation mode

powercfg -h off

deletes hyberfiles.sys wich can store more than 3 / 4 GB of data

4.Delete the following content from this folders

del C:\Windows\Prefetch\*.* /Q
del C:\Windows\Temp\*.* /Q
del C:\Windows\SoftwareDistribution\*.* /Q