get volume serial number

Discussion in 'ASP .Net Building Controls' started by TJS, Dec 31, 2003.

  1. TJS

    TJS Guest

    can anyone help me get this working for asp.net server control using vb ?

    doesn't compile, error on "disk.Properties" and "response.write"

    ==============command line================

    vbc /t:library /out:volume.dll /r:System.web.dll /r:System.dll
    /r:System.Management.dll /r:System.Web.dll *.vb
    pause

    ================code=================
    Imports System
    Imports System.Management
    Imports System.web

    Class Disk
    Public Shared Sub Main()
    Dim drive As String = "C"
    Dim disk As ManagementObject = New ManagementObject("Win32_Logicaldisk="
    + "\"" + drive + ":\"")
    Dim VolumeName As String =
    disk.Properties("Volumename").Value.ToString()
    Dim SerialNumber As String =
    disk.Properties("Volumeserialnumber").Value.ToString()
    Response.write("{0} - {1}", VolumeName, SerialNumber)
    End Sub
    End Class
     
    TJS, Dec 31, 2003
    #1
    1. Advertising

  2. Hi,

    Dim moReturn As Management.ManagementObjectCollection

    Dim moSearch As Management.ManagementObjectSearcher

    Dim mo As Management.ManagementObject

    moSearch = New Management.ManagementObjectSearcher("Select * from
    Win32_LogicalDisk where Name = 'C:'")

    moReturn = moSearch.Get

    For Each mo In moReturn

    Dim VolumeName As String = mo("Volumename")

    Dim SerialNumber As String = mo("Volumeserialnumber")

    Dim strOut As String = String.Format("{0} - {1}", VolumeName, SerialNumber)

    Debug.WriteLine(strOut)

    Next

    Ken

    -------------------

    "TJS" <> wrote in message
    news:ORM66$...
    > can anyone help me get this working for asp.net server control using vb ?
    >
    > doesn't compile, error on "disk.Properties" and "response.write"
    >
    > ==============command line================
    >
    > vbc /t:library /out:volume.dll /r:System.web.dll /r:System.dll
    > /r:System.Management.dll /r:System.Web.dll *.vb
    > pause
    >
    > ================code=================
    > Imports System
    > Imports System.Management
    > Imports System.web
    >
    > Class Disk
    > Public Shared Sub Main()
    > Dim drive As String = "C"
    > Dim disk As ManagementObject = New
    > ManagementObject("Win32_Logicaldisk="
    > + "\"" + drive + ":\"")
    > Dim VolumeName As String =
    > disk.Properties("Volumename").Value.ToString()
    > Dim SerialNumber As String =
    > disk.Properties("Volumeserialnumber").Value.ToString()
    > Response.write("{0} - {1}", VolumeName, SerialNumber)
    > End Sub
    > End Class
    >
    >
     
    Ken Tucker [MVP], Dec 31, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. MRAB
    Replies:
    3
    Views:
    1,125
    Paul Boddie
    Jun 4, 2009
  2. Max Kotasek
    Replies:
    4
    Views:
    989
    Max Kotasek
    Apr 9, 2010
  3. Sven
    Replies:
    2
    Views:
    182
  4. Ned Deily
    Replies:
    0
    Views:
    113
    Ned Deily
    Apr 3, 2013
  5. Sven
    Replies:
    0
    Views:
    141
Loading...

Share This Page