I was looking for a quick and easy way to get directory and file size for a given directory and its sub-directories.  I came across a nice post by Luis Diego Fallus and ended up using a commenter’s code to produce output in MB format.

gci . | %{$f=$_; gci -r $_.FullName |
	measure-object -property length -sum |
		select @{Name="Name"; Expression={$f}} ,
		@{Name="Sum (MB)"; Expression={ "{0:N3}" -f ($_.sum / 1MB) }}, Sum } |
	sort Sum -desc | format-table -Property Name,"Sum (MB)" -autosize

Example Output

Name                  Sum (MB)
----                  --------
Adobe                 1,603.809
TestDirectory         67.715

Rob van der Woude has a nice batch script to get disk usage of folders & subfolders in Windows since there isn’t a built-in function.  This could be similar to Linux du command.

 

@ECHO OFF
:: Use local variables
IF "%OS%"=="Windows_NT" SETLOCAL

:: Check command line arguments and Windows version
ECHO.%1 | FIND "/" >NUL
IF NOT ERRORLEVEL 1 IF /I NOT "%~1"=="/L" GOTO Syntax
ECHO.%1 | FIND "?" >NUL
IF NOT ERRORLEVEL 1 GOTO Syntax
ECHO.%1 | FIND "*" >NUL
IF NOT ERRORLEVEL 1 GOTO Syntax
IF NOT "%OS%"=="Windows_NT" GOTO Syntax
IF NOT "%~1"=="" IF /I NOT "%~1"=="/L" IF NOT EXIST "%~1" GOTO Syntax
SET LongFormat=1
IF /I NOT "%~1"=="/L" IF /I NOT "%~2"=="/L" SET LongFormat=0

:: Go to start directory
SET StartDir=%CD%
IF NOT "%~1"=="" IF /I NOT "%~1"=="/L" SET StartDir=%~1
PUSHD "%StartDir%"
IF ERRORLEVEL 1 GOTO Syntax

:: Display header
ECHO Directory	Space used (MB)
ECHO.=========	===============

:: Display disk usage for start directory
IF NOT EXIST *.* GOTO SubDirs
FOR /F "tokens=3,4*" %%A IN ('DIR %1 /A-D /-C ^| FIND /I "File(s)"') DO SET ListDir=%%A
:: Different procedures depending on /L switch
IF "%LongFormat%"=="1" GOTO LongFormat
SET /A ListDir=%ListDir%+524288
SET /A ListDir=%ListDir%/1048576
ECHO..	%ListDir%
SET ListDir=
GOTO SubDirs
:LongFormat
:: Strip last 6 digits from value
SET ListDir=%ListDir:~0,-6%
IF NOT DEFINED ListDir SET ListDir=0
:: Display resulting value in MB
ECHO..	%ListDir%
:: Clear variable
SET ListDir=


:: Display disk usage for every subdirectory
:SubDirs
FOR /D %%A IN (*.*) DO CALL :List%LongFormat% "%%~A"

:: Done
POPD
GOTO End


:List0
:: Set variable value to bytes used by directory
FOR /F "tokens=3,4*" %%B IN ('DIR /A /-C /S "%~1" ^| FIND /I "File(s)"') DO SET ListDir=%%~B
:: Add 0.5MB in order to properly round the value when integer divided by 1MB
SET /A ListDir=%ListDir%+524288
:: Integer divide by 1MB
SET /A ListDir=%ListDir%/1048576
:: Display resulting value in MB
ECHO.%~1	%ListDir%
:: Clear variable
SET ListDir=
GOTO:EOF


:List1
:: Set variable value to bytes used by directory
FOR /F "tokens=3,4*" %%B IN ('DIR /A /-C /S "%~1" ^| FIND /I "File(s)"') DO SET ListDir=%%~B
:: Strip last 6 digits from value
SET ListDir=%ListDir:~0,-6%
IF NOT DEFINED ListDir SET ListDir=0
:: Display resulting value in MB
ECHO.%~1	%ListDir%
:: Clear variable
SET ListDir=
GOTO:EOF


:Syntax
ECHO.
ECHO DiskUse, Version 5.01 for Windows 2000 / XP
ECHO Display disk space used by subdirectories (tab delimited)
ECHO.
ECHO Usage:  DISKUSE  [ startdir ]  [ /L ]
ECHO.
ECHO Where:  "startdir"  is the directory containing subdirectories to be
ECHO                     inventoried (default is the current directory)
ECHO         "/L"        is used for large numbers, over 2GB, to prevent return
ECHO                     of negative numbers due to batch math limitations
ECHO                     (integer division by 1000000 instead of properly
ECHO                     rounded mathematical division by 1048576)
ECHO.
ECHO Written by Rob van der Woude
ECHO http://www.robvanderwoude.com

:End
IF "%OS%"=="Windows_NT" ENDLOCAL

Here’s a query I found that helps show database IO consumption.

 SELECT
        DB_NAME(DB_ID('DATABASENAME')) AS [Database Name]
      , mf.physical_name
      , io_stall_read_ms
      , num_of_reads
      , CAST(io_stall_read_ms / (1.0 + num_of_reads) AS NUMERIC(10, 1)) AS [avg_read_stall_ms]
      , io_stall_write_ms
      , num_of_writes
      , CAST(io_stall_write_ms / (1.0 + num_of_writes) AS NUMERIC(10, 1)) AS [avg_write_stall_ms]
      , io_stall_read_ms + io_stall_write_ms AS [io_stalls]
      , num_of_reads + num_of_writes AS [total_io]
      , CAST((io_stall_read_ms + io_stall_write_ms)
        / (1.0 + num_of_reads + num_of_writes) AS NUMERIC(10,1)) AS [avg_io_stall_ms]
    FROM
        sys.dm_io_virtual_file_stats(NULL, NULL) AS fs
    INNER JOIN sys.master_files AS mf
    ON  fs.database_id = mf.database_id
        AND fs.[file_id] = mf.[file_id]
    ORDER BY
            [Database Name] ASC, mf.physical_name
--  num_of_reads DESC
--  num_of_writes DESC
    OPTION (RECOMPILE) ;

TAPEDRIVE NOTES (LINUX 2.4)
-Rich (01/08/2004)

Rewind tape drive:

# mt -f /dev/st0 rewind

Backup directory /www and /home with tar command (z – compressed):

# tar -czf /dev/st0 /www /home

Find out what block you are at with mt command:

# mt -f /dev/st0 tell

Display list of files on tape drive:

# tar -tzf /dev/st0

Restore /www directory:

# cd /
# mt -f /dev/st0 rewind
# tar -xzf /dev/st0 www

Unload the tape:

# mt -f /dev/st0 offline

Display status information about the tape unit:

# mt -f /dev/st0 status

Erase the tape:

# mt -f /dev/st0 erase

You can go BACKWARD or FORWARD on tape with mt command itself:
(a) Go to end of data:

# mt -f /dev/nst0 eod

(b) Goto previous record:

# mt -f /dev/nst0 bsfm 1

(c) Forward record:

# mt -f /dev/nst0 fsf 1 

Replace /dev/st0 with your actual tape drive name.

What is it?

I created a small tool to help facilitate setting the default user to automatically logon to a system.

Requirements

  • Administrator Privileges
  • .NET 2.0 or greater

Details

There are 4 registry entries of interest here:

[HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindows NTCurrentVersionWinlogon]
AutoAdminLogon=1
DefaultUserName=
DefaultPassword=
ForceAutoLogon=1

If you don’t want to download and run my program, you can simply copy the above text into notepad, save-as a .reg file and double-click it to run it. Make sure you take care to modify the settings as necessary.

The convenience of my application is that it will list local users so you can simply just click on the desired user and set the information accordingly.

Screenshots

2013-01-30_092244

Download

Download from here:  AutoLogon (62KB)

Changelog

  • 1/30/2012 – Added Show/Hide for password box and set default to hide password.
  • 1/29/2012 – Initial Release for Testing
s
search
c
compose new post
r
reply
e
edit
t
go to top
j
go to the next post or comment
k
go to the previous post or comment
o
toggle comment visibility
esc
cancel edit post or comment