Find free disk space command

Microsoft Windows xp professional (upgr...
December 17, 2009 at 06:59:29
Specs: Windows XP
Hi,

I am wanting to run a command/script on all my XP workstations that will report the free disk space + total disk space + computer name + ip address and save it to a file.

Any ideas?

Cheers
Michael


See More: Find free disk space command

Report •


#1
December 17, 2009 at 08:24:04
Do you need the report in a free-text format, or should it be very syntax specific ?

In the first case, this may do:

@echo off
dir C:\ > c:\info.log
echo %computername% >> c:\info.log
ipconfig >> c:\info.log

But this is missing the total bytes the C-drive can contain


Report •

#2
December 17, 2009 at 10:08:20
For total space you need CHKDSK.


=====================================
Helping others achieve escape felicity

M2


Report •

#3
December 17, 2009 at 16:57:37
Instead of chkdsk couldn't we use:

dir %systemdrive% | Findstr Dir(s)

?


Report •

Related Solutions

#4
December 17, 2009 at 20:57:48
You may want to have a look at this:

http://pastebin.com/m76173344

Just be aware dir simply doesn't pick up all of the used space, even with /a.

It's a huge mess but it seems to work on my end, and I don't particularly want to screw with it at the moment.


Batch Variable how to


Report •

#5
December 18, 2009 at 02:06:01
#3,

You can Findstr Dir(s) all you want.

It doesn't give total space.


=====================================
Helping others achieve escape felicity

M2


Report •

#6
December 18, 2009 at 02:07:39
Thanks guys,

My scripting skills are very rusty. Usually I use Zenworks inventory which gives me exactly what I want but this company won't have it implemented in time.

tvc - I only want to strip the value for free/total space + computer and export to txt or csv file as I'm dealing with 1000 or so pcs (if possible).

Mechanix2Go - chkdsk is VERY slow.. is there nothing else that can extract total disk size?

viddywell - Yes i was looking at a command which is basically the same: dir | find "free" I can't however find a command that gets the total disk size. Also how do I get computer name extracted into a csv or txt as the next value?

Judago - That is what i am looking for, just need to have it with no user interaction and extract only the values to a file.


Report •

#7
December 18, 2009 at 03:11:16
CHKDSK is slow indeed, but it's a batch process, so who cares ? You may use it to check drives (in an automated manner of course) of those 1000 PC's ...

Here's my best attempt:

@echo off
echo %computername% > c:\info_%COMPUTERNAME%.log
ipconfig | findstr /C:"IP Address" >> c:\info_%COMPUTERNAME%.log
dir | findstr /C:"bytes free" >> c:\info_%COMPUTERNAME%.log
chkdsk C: | findstr /C:"total disk space" >> c:\info_%COMPUTERNAME%.log 2> nul

type C:\info_%COMPUTERNAME%.log


Report •

#8
December 18, 2009 at 03:47:32
I only want to strip the value for free/total space + computer and export to txt or csv file as I'm dealing with 1000 or so pcs (if possible).

I know this was for tvc but I'm a little tired or rolling around in the dark. What exact format and information do you want?

Something like this:

<computername>, <ip address>, <disk total>, <disk free>

Which ip address are you after? Execute "ipconfig /all" and pick the name of the entry (i.e. "Physical Address....", "IP Address...", "Default Gateway", ect).

Are you only after the size of the base volume (i.e %systemdrive% - usually c:) or do you want list all drives, if you want all drives how do you want the extra info formatted.

As for my script what base unit are you interested in? (b, kb, mb, gb)?

Judago - That is what i am looking for, just need to have it with no user interaction and extract only the values to a file.

Easily done, as long as I know exactly how you want the data.

I don't mean to be grouchy but without some solid requirements this just takes too long with much wasted effort.


Batch Variable how to


Report •

#9
December 18, 2009 at 04:05:31
Here's just my guess:

http://pastebin.com/m3758f80e

Outputs to "somereport.txt" with:

computername, ip address, disk total gb, disk free gb

Disk is assumed to be %systemdrive%, usually c:.


Batch Variable how to


Report •

#10
December 18, 2009 at 04:08:34
Guys, all the answers I've seen so far seem to be designed to work on the local machine. Micka, aren't you after a utility that will check the disk sizes remotely?

Report •

#11
December 18, 2009 at 04:27:35
Judago your right on the money :)

Sorry I'll be more specific next time. That is exactly how I want it apart from the total disk size value which is showing up as 2.5GB when its a 75GB disk. Any ideas where its pulling this size from? Apart from that its perfect!

Klint - this batch will work on remote pcs by auto-runing the script on startup or Zenworks refresh stage. Then I'll just point the output to a file on a network drive.


Report •

#12
December 18, 2009 at 04:54:49
A backslash can be worth so much:

http://pastebin.com/m6bff329a

[edit]
Explaination:

%Systemdrive% expands without a backslash, if the current directory is a subdir of %systemdrive% and dir is run without the backslash it will only start counting from below the current directory, not from the root...
[/edit]



Batch Variable how to


Report •

#13
December 18, 2009 at 05:16:48
Great work.. thats much better.

It now shows 68.9893GB for a 80GB (75GB after installing) but I only need a rough idea for the total disk size so that will work just fine.

Thanks for your help!


Report •

#14
December 18, 2009 at 05:27:50
Yeah as I mentioned in #4 dir simply won't output *every* last byte, I think windows counts losses for the file system and the like.

Your example is a lot worse than my system though, I have an 80gb and I'm getting 74.4720 for total, maybe it doesn't count system restore, which I have turned off.........


Batch Variable how to


Report •

#15
December 18, 2009 at 05:34:12
Fair enough.. I don't have system restore enabled either but I can live with a few GB off.

Thanks again


Report •

#16
December 18, 2009 at 05:38:36
No problem, glad I could help!


Batch Variable how to


Report •

#17
December 18, 2009 at 06:34:16
Is it possible include a date and time stamp on it?

Also my managers are freaking out over office 2007 rollout (lol) so wanting all system details - CPU speed, RAM size.

I know systeminfo command will get this info I just suck at scripting so don't know how to extract it.


Report •

#18
December 18, 2009 at 07:13:04
What exact info do you want, can you show me the mock csv?


Batch Variable how to


Report •

#19
December 18, 2009 at 07:31:25
Guessing again.....

http://pastebin.com/m48c8d5d4


Batch Variable how to


Report •

#20
December 18, 2009 at 08:20:25
In my hunt for a debug script I found this vbs. Anybody know how to make it work?

==================================

' LogicalDisk.vbs
' Sample VBScript to interrogate a Logical disk with WMI
' Author Guy Thomas <a href="http://computerperformance.co.uk/" target="_blank">http://computerperformance.co.uk/</a>
' Version 1.8 - November 2005
' -------------------------------------------------------------'
Option Explicit
Dim objWMIService, objItem, colItems, strComputer

On Error Resume Next
strComputer = "."

Set objWMIService = GetObject _
("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery _
("Select * from Win32_LogicalDisk")

For Each objItem in colItems
Wscript.Echo "Computer: " & objItem.SystemName & VbCr & _
" ==================================" & VbCr & _
"Drive Letter: " & objItem.Name & vbCr & _
"Description: " & objItem.Description & vbCr & _
"Volume Name: " & objItem.VolumeName & vbCr & _
"Drive Type: " & objItem.DriveType & vbCr & _
"Media Type: " & objItem.MediaType & vbCr & _
"VolumeSerialNumber: " & objItem.VolumeSerialNumber & vbCr & _
"Size: " & Int(objItem.Size /1073741824) & " GB" & vbCr & _
"Free Space: " & Int(objItem.FreeSpace /1073741824) & _
" GB" & vbCr & _
"Quotas Disabled: " & objItem.QuotasDisabled & vbCr & _
"Supports DiskQuotas: " & objItem.SupportsDiskQuotas & vbCr & _
"Supports FileBasedCompression: " & _
objItem.SupportsFileBasedCompression & vbCr & _
"Compressed: " & objItem.Compressed & vbCr & _
""
Next

WSCript.Quit

' End of Sample DiskDrive VBScript


=====================================
Helping others achieve escape felicity

M2


Report •

#21
December 18, 2009 at 08:26:20
Anybody know how to make it work?

I'm ignorant to vbs but it did work fine on my machine, it didn't work with cscript though.

It would make for a much better solution....


Batch Variable how to


Report •

#22
December 18, 2009 at 08:49:13
"it did work fine on my machine"

How?


=====================================
Helping others achieve escape felicity

M2


Report •

#23
December 18, 2009 at 08:53:06
Jadago you guessed right again.. hopefully this will settle the managers down abit otherwise I'll have you writing a full inventory program lol.

Not a big issue but can you filter the CPU info to just the speed - ie. 2593 Mhz?

Cheers!


Report •

#24
December 18, 2009 at 09:20:55
M2,

I just double clicked on it. It opened up a dialog box with stats and "ok", clicking on "ok" opened up the stats for the next drive. I tried it from the cli with "cscript test.vbs" and it didn't work. Maybe your default is scipt engine is cscript or perhaps the wmi class isn't part of win2k.....


Jadago you guessed right again.. hopefully this will settle the managers down abit otherwise I'll have you writing a full inventory program lol.

Who do I make the invoice out to?


This should do it:

http://pastebin.com/m1e7659b6


Batch Variable how to


Report •

#25
December 18, 2009 at 10:12:28
Hi Judago,

I have used other vbs posted here. Ill dig one up for an example.

TY


=====================================
Helping others achieve escape felicity

M2


Report •

#26
December 18, 2009 at 10:20:57
Hi M2,

It would definitely be a better outcome, probably more reliable too.

I can see the need, my script is a bit of an abomination, stitched together from old projects - I hit ^d and scream "it's ALIVE!!", now I can't sleep for fear of the villagers.......


Batch Variable how to


Report •

#27
December 18, 2009 at 10:33:11
I'm still looking for a debug solution.


=====================================
Helping others achieve escape felicity

M2


Report •

#28
December 18, 2009 at 12:14:26
Great.. thats perfect. Office 2007 here we come :)

Thanks!


Report •

#29
December 19, 2009 at 01:07:00
By the way, dir won't count alternative data streams. For
example, say you have a 3 GB file and you append it to an
alternative data stream of a 1 KB byte and then delete the 3 GB
file, the dir command will not count the 3 GB but they will still
take up space on your drive. If a mischievous user does that 10
times, there's 30 GB suddenly gone missing. So, consider using
this command instead:

fsutil volume diskfree %SystemDrive%


Report •

#30
December 19, 2009 at 01:29:57
I forgot about alternate data streams:Ha ha! dir can't get me now!!!

Fsutil is a better choice, provided that the volume is ntfs, with xp this isn't guaranteed, even for %systemdrive%.


Batch Variable how to


Report •


Ask Question