Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Volume list from script

Posted on 2005-04-25
8
Medium Priority
?
850 Views
Last Modified: 2008-01-09
Hello,

I would like to create a script for showing all volumes (especially free space on them) from command line. Result should be in text for similar to what we seen in Computer Management mmc.
In W2k3 this is not problem using Win32_Volume WMI class, but neither Win32_Volume, nor Win32_DefragAnalysis (which could be used as well) is able to use in Win2000 (there are simply not implemented).
I found a way using Win32_DiskPartition, but there is no infromation about free space, and I did not find any way to find it.
Maybe WMI is not a way on Win2000 ... ??!!

Do you have any idea how to handle this? (Volume name, free space, ev. mount point).

Thanks!

Peter
0
Comment
Question by:PeterR78
8 Comments
 
LVL 10

Expert Comment

by:ADSaunders
ID: 13857127
Hi PeterR78,
Try This for size ... Cut & paste into a .vbs file and run it from a command window.

Dim fso, Mydrives, d, s
Set fso = createobject ("Scripting.FileSystemObject")
Set Mydrives = fso.Drives
For Each d In MyDrives
      s = d.DriveLetter & " - " 
      Select Case d.DriveType
        Case 0: s = s & " " & "Unknown "
        Case 1: s = s & " " & "Removable "
        Case 2: s = s & " " & "Fixed "
        Case 3: s = s & " " & "Network "
        Case 4: s = s & " " & "CD-ROM "
        Case 5: s = s & " " & "RAM Disk "
      End Select
    If d.DriveType = 3 Then
      s = s &  d.ShareName
    ElseIf d.IsReady Then
        if d.VolumeName = "" Then
            s = s & "<Unlabelled>"
        else
          s = s &  d.VolumeName
      end if
    End If
    s = s & " " 
    If d.IsReady Then
        s = s & FormatNumber(d.AvailableSpace/1024, 0)
    End if
    wscript.echo s
Next
Set d = Nothing
Set MyDrives = Nothing
Set FSO = nothing


Regards .. Alan
0
 

Author Comment

by:PeterR78
ID: 13857524
Hello Alan,

well, this is exactly what I don't need :-(.

This show you only logical volumes with assigned letter (a:, c:, d:...).

What I need is a mount point list with free space. E.g.:

Volume name;Filesystem;Mount point;Free space
Archive1;NTFS;c:\data\archive1;802MB
Archive2;NTFS;c:\data\archive2;250GB
...

But thank you very much anyway!

Peter
0
 
LVL 71

Expert Comment

by:Chris Dent
ID: 13857862
Hi Peter,

I think the file system object can do it, and Alan's suggestion isn't far off just needs different properties, but I have nothing to test it with here. Can you try this one (vbscript again)?


Option Explicit

Dim objFileSystem, objDrives, objDrive
Dim strVolumeName, strMountPoint
Dim dblFreeSpace

Set objFileSystem = CreateObject("Scripting.FileSystemObject")
Set objDrives = objFileSystem.Drives

For Each objDrive in objDrives

    ' Display Properties for Fixed Drive only

    If (objDrive.DriveType = 2) Then
        strVolumeName = objDrive.VolumeName
        strMountPoint = objDrive.RootFolder
        dblFreeSpace = objDrive.FreeSpace

        dblFreeSpace = dblFreeSpace / (1024 * 1024 * 1024)
        dblFreeSpace = FormatNumber(dblFreeSpace, 2)

        wscript.echo strVolumeName & ";" & strMountPoint & ";" & dblFreeSpace & " GB"
    End If
Next

HTH

Chris
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 

Author Comment

by:PeterR78
ID: 13857946
Hello Chris,

I am affraid, it's not IT again.

Suppose you have attached NAS storage device, but not to a letter, but to a directory in your existing directory structure.

What your script do is again only list of fixed drives with letter.

But thanks anyway!

Peter
0
 
LVL 71

Expert Comment

by:Chris Dent
ID: 13858003

Ahh sorry, the fixed drive selection was by choice, I assumed you were referring to physical drives mounted at a different point. But it's not the only option it can pick.

Want to try this one?

Option Explicit

Dim objFileSystem, objDrives, objDrive
Dim strVolumeName, strMountPoint
Dim dblFreeSpace

Set objFileSystem = CreateObject("Scripting.FileSystemObject")
Set objDrives = objFileSystem.Drives

For Each objDrive in objDrives

    ' Display properties for drives reporting Ready only

    If objDrive.IsReady Then
        strVolumeName = objDrive.VolumeName
        strMountPoint = objDrive.RootFolder
        dblFreeSpace = objDrive.FreeSpace

        dblFreeSpace = dblFreeSpace / (1024 * 1024 * 1024)
        dblFreeSpace = FormatNumber(dblFreeSpace, 2)

        wscript.echo strVolumeName & ";" & strMountPoint & ";" & dblFreeSpace & " GB"
    End If
Next
0
 

Author Comment

by:PeterR78
ID: 13864678
Hello Chris,

again, this will show only drives/volumes assigned to a letter.

I need a list of volumes assigned to a directory.

But thank you anyway!

Best regards,

Peter
0
 
LVL 31

Expert Comment

by:Wayne Barron
ID: 15722089
No comment has been added to this question in more than 21 days, so it is now classified as abandoned..
I will leave the following recommendation for this question in the Cleanup topic area:
[PAQ - Refund]

Any objections should be posted here in the next 4 days. After that time, the question will be closed.

Carrzkiss
EE Cleanup Volunteer
0
 
LVL 1

Accepted Solution

by:
Computer101 earned 0 total points
ID: 15760662
PAQed with points refunded (125)

Computer101
EE Admin
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

NTFS file system has been developed by Microsoft that is widely used by Windows NT operating system and its advanced versions. It is the mostly used over FAT file system as it provides superior features like reliability, security, storage, efficienc…
MSSQL DB-maintenance also needs implementation of multiple activities. However, unprecedented errors can hamper the database management. In that case, deploying Stellar SQL Database Toolkit ensures fast and accurate database and backup repair as wel…
Integration Management Part 2
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Suggested Courses

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question