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

  • With JRebel, developers get to see their code changes immediately, fine-tune their code with incremental changes, debug, explore and deploy their code with ease (both locally and remotely), and ultimately spend more time coding instead of waiting for the dreaded application redeploy to finish. Every time a developer tests a code change it takes minutes to build and deploy the application. JRebel keeps the app server running at all times, so testing is instantaneous and interactive.

  • Instead of only managing projects organizations do need to manage value! "Doing the right things" and "doing things right" are the essential ingredients for successful software and systems delivery. Unfortunately, with distributed delivery spanning multiple disciplines, geographies and time zones, many organizations struggle with teams working in silos, broken lines of communication, lack of collaboration, inadequate traceability, and poor project visibility. This often results in organizations "doing the …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds