954,568 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?

Get HD Info

0
By alex_extreme on Apr 9th, 2005 2:05 am

Gets the names of all the partitions in a system. Note that media must be in every removable drive for this to work (can be fixed easily)

' GetHDInfo - Get names of all the partitions and drives on a system

Dim FSO, d, Drives, MyStr, n
' Create the FileSystemObject
Set FSO = CreateObject("Scripting.FileSystemObject")
' Get the list of drives
Set Drives = FSO.Drives
' Go through the drives and get names
For Each d In Drives
    MyStr = MyStr & d.DriveLetter & " - "
    If d.DriveType = 3 Then
        n = d.ShareName
    Else
        n = d.VolumeName
    End If
    MyStr = MyStr & n & vbCrLf
Next
MsgBox MyStr

how to use?
..where should i put this coding?

kouji108
Newbie Poster
1 post since Feb 2008
Reputation Points: 10
Solved Threads: 0
 

If a drive has no title or the title is "" then can't read d.VolumeName and program will crash.

Replace

n = d.VolumeName

with

On Error Resume Next
        n = ""
        n = d.VolumeName
Mark A
Newbie Poster
2 posts since Aug 2011
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You