954,568 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

assign drive letter to hard disc using it serial number or name

Hi.
I am looking for vba or vb code to unassign, assign, switch, drive letter.
The hard disc will be identified by its serial number or by its name.
Thanks in advance.
asihuay

asihuay
Newbie Poster
2 posts since Mar 2008
Reputation Points: 10
Solved Threads: 0
 

this following code to read name and serial number of HD :

Private Type DRIVEINFO
    HDDModel As String
    HDDIType As String
    HDDSerialNum As String
End Type
   
Dim info As DRIVEINFO
Public Function HDDSerialNumber()
Dim objs As Object
Dim obj As Object
Dim WMI As Object
    
    Set WMI = GetObject("WinMgmts:")
    Set objs = WMI.InstancesOf("Win32_DiskDrive")
    For Each obj In objs
        info.HDDModel = obj.Model
        info.HDDIType = obj.InterfaceType
    Next obj
    
    Set objs = WMI.InstancesOf("Win32_PhysicalMedia")
    For Each obj In objs
        info.HDDSerialNum = obj.SerialNumber
    Next obj
    Text1.Text = info.HDDModel
    Text2.Text = info.HDDIType
    Text3.Text = info.HDDSerialNum
End Function

Private Sub Form_Load()
HDDSerialNumber
End Sub
Jx_Man
Nearly a Senior Poster
3,329 posts since Nov 2007
Reputation Points: 1,372
Solved Threads: 444
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You