Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

customizing output from freedisk DOS command

Status
Not open for further replies.

y2k1981

Programmer
Aug 2, 2002
773
IE
I have 2 questions regarding the freedisk commnad on 2003 server, both of which are related. I want to use freedisk to return the amount of freedisk space available on a volume. However, I'd like it return in Mega Bytes instead of bytes. Is there anyway around this at all?

Also, Is there anyway to just return the value with out the INFO: infront? So basically I'd like either 1500MB of just 1500 returned as the value - without any comman to separate the thousands etc. Does anybody think this is possible at all?
 
Nope - freedisk won't do it. This will though:
Code:
Set objWMIService = GetObject("winmgmts:")
Set objLogicalDisk = objWMIService.Get("Win32_LogicalDisk.DeviceID='c:'")
Wscript.Echo Round(objLogicalDisk.FreeSpace / 1048576) & " MB"

It's rough and ready but will give you the free disk space on C:. Save it as a vbs file (e.g. space.vbs) and execute it as:

cscript space.vbs //nologo

If you don't like the MB the just delete it from the last line above.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top