get volume serial number

T

TJS

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
 
K

Ken Tucker [MVP]

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top