Disk Serial Number'�Using the WMI Scripting Library


' Retreives the drive serial number in a Win32 system.
' This is a great example of how to use the WMI scripting library.
'
' The latest version of the library can be downloaded from Microsoft.
'
' The WMI Scripting type library must be referenced to use this routine.
'
' to add the WMI Scripting type library to the project references
'
'   1.Select References from the Project menu.
'
'   2.In the Available References dialog box, select Microsoft WBEM
'     Scripting V1.0 Library or Microsoft WMI Scripting V1.1
'     Library (whichever appears).
'
'   3.If no suitable option appears in the Available References list,
'      add it by using the Browse button in the References dialog
'      box. The Browse button opens an Add Reference dialog box
'      that enables you to locate the WbemScripting type library.
'      The WbemScripting type library resides in the file
'      Wbemdisp.tlb in the Wbem installation directory. on
'      computers with the Windows 98 operating system, this type
'      library is located in the WindowsSystemWbem directory.
'     On computers with the Microsoft. Windows NT./Windows 2000
'      operating system, this type library is located in the
'      WinntSystem32Wbem directory.
'
'   4.Select the file and click Open. Microsoft WBEM Scripting V1.0
'      Library or Microsoft WMI Scripting V1.1 Library appears on
'      the references list.
' Make sure you select the check the box next to this item in the list.
'
'
Sub main()
'
  set objinst = GetObject("WinMgmts::Win32_LogicalDisk='C:'")
  MsgBox (GetObject "WinMgmts::Win32_LogicalDisk='C:'").
          VolumeSerialNumber)
'
End Sub



Comments

  • There are no comments yet. Be the first to comment!

Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • Live Event Date: December 11, 2014 @ 1:00 p.m. ET / 10:00 a.m. PT Market pressures to move more quickly and develop innovative applications are forcing organizations to rethink how they develop and release applications. The combination of public clouds and physical back-end infrastructures are a means to get applications out faster. However, these hybrid solutions complicate DevOps adoption, with application delivery pipelines that span across complex hybrid cloud and non-cloud environments. Check out this …

  • On-demand Event Event Date: October 29, 2014 It's well understood how critical version control is for code. However, its importance to DevOps isn't always recognized. The 2014 DevOps Survey of Practice shows that one of the key predictors of DevOps success is putting all production environment artifacts into version control. In this webcast, Gene Kim discusses these survey findings and shares woeful tales of artifact management gone wrong! Gene also shares examples of how high-performing DevOps …

Most Popular Programming Stories

More for Developers

RSS Feeds