1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Batch Script to list Drives and Types

Discussion in 'Programming' started by Cleptography, Sep 6, 2010.

  1. Cleptography

    Cleptography New Member

    Joined:
    Sep 2, 2010
    Messages:
    39
    Likes Received:
    7
    Trophy Points:
    0
    This .bat file uses fsutil to get a list of the drives and types on a windows machine.

    Batch Script to list Drives and Types
    ------------------------------------------
    Code:
    @echo off
     setlocal
    
    ::
    REM Get and list drive types using fsutil
    ::
    	set "list="
    	
    	for /f "tokens=*" %%a in ('^
    	fsutil fsinfo drives^|^
    	find /V ""'
    
    ) do (
    
    	set "dv=%%a"
    	call set "list=%%list%% %%dv:~-3%%"
    )
    	for %%a in (%list%) do (
    	fsutil fsinfo drivetype %%a
    )
     
  2. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,283
    Likes Received:
    364
    Trophy Points:
    83
  3. Cleptography

    Cleptography New Member

    Joined:
    Sep 2, 2010
    Messages:
    39
    Likes Received:
    7
    Trophy Points:
    0
    The original above script does not apply to Windows 7 instead use this to pipe the info using DiskPart
    Code:
    @echo off
    
    echo.list vol | DiskPart | find /i "partition"
    echo.list vol | DiskPart | find /i "DVD-ROM"
    echo.list vol | DiskPart | find /i "Removable"
     
    Last edited: Mar 13, 2011

Share This Page