Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 692227
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T02:37:44+00:00 2026-05-14T02:37:44+00:00

Is it possible to programatically find the free space available in mapped drives? How

  • 0

Is it possible to programatically find the free space available in mapped drives?

How to find the percentage of free space in your drive using ms-dos.
It may be easy to find the free space for a drive in ur hard disc but i need to find the free-space of mapped drives.

I have mapped some file servers in my systems.

It is possible to see this in My Computer, but how do show it in a command prompt?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T02:37:45+00:00Added an answer on May 14, 2026 at 2:37 am

    (Taken from an old answer of mine over at Server Fault)

    The easiest way to reliably get at the free disk space is using WMI. When trying to parse the output of dir you get all kinds of funny problems, at the very least with versions of Windows in other languages. You can use wmic to query the free space on a drive:

    wmic logicaldisk where "DeviceID='C:'" get FreeSpace
    

    This will output something like

    FreeSpace
    197890965504
    

    You can force this into a single line by adding the /format:value switch:

    > wmic logicaldisk where "DeviceID='C:'" get FreeSpace /format:value
    
    FreeSpace=197890965504
    

    There are a few empty lines there, though (around three or four) which don’t lend themselves well for processing. Luckily the for command can remove them for us when we do tokenizing:

    for /f "usebackq delims== tokens=2" %x in (`wmic logicaldisk where "DeviceID='C:'" get FreeSpace /format:value`) do set FreeSpace=%x
    

    The nice thing here is that since we’re only using the second token all empty lines (that don’t have a second token) get ignored.

    Remember to double the % signs when using this in a batch file:

    for /f "usebackq delims== tokens=2" %%x in (`wmic logicaldisk where "DeviceID='C:'" get FreeSpace /format:value`) do set FreeSpace=%%x
    

    You can now use the free space which is stored in the environment variable %FreeSpace%.


    Getting percentages now is a little tricky since batch files only support 32-bit integers for calculation. However, you probably don’t need to calculate this to the byte; I think megabytes are quite enough:

    for /f "usebackq delims== tokens=2" %%x in (`wmic logicaldisk where "DeviceID='C:'" get FreeSpace /format:value`) do set FreeSpace=%%x
    for /f "usebackq delims== tokens=2" %%x in (`wmic logicaldisk where "DeviceID='C:'" get Size /format:value`) do set Size=%%x
    set FreeMB=%FreeSpace:~0,-6%
    set SizeMB=%Size:~0,-6%
    set /a Percentage=100 * FreeMB / SizeMB
    echo C: is %Percentage% % free
    

    This should work unless your volumes get larger than 20 TiB.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: How to block a website programatically using DotNet HAI I am developing
I'd like to programatically analyze the content of a website and find possible spots
Possible Duplicate: Any way to add HttpHandler programatically in .NET? Is there a way
Is it possible to enable a second monitor programatically and extend the Windows Desktop
Is it possible to generate a XML Schema of a Database programatically with .Net
Is it possible to change the BB Messenger's status programatically? As of now I
is it possible to extract dynamic loaded text from a swf (flash application) programatically
Possible Duplicate: How to programatically take a screenshot on Android? How to capture the
I am trying to programatically generate movie/video file using Google Earth COM APIs (along
Possible Duplicate: How to find out if a .NET assembly was compiled with the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.