请注意,我是 WMI 的新手,大部分时间都在研究这个问题,即使有数百个帖子,我仍在努力寻找有关这个特定问题的任何帮助。
使用 Win32_DiskDrive - 标题和名称函数时遇到问题:当我执行 VB.script 时:尝试 Dim connection As New ConnectionOptions connection.Username = userNameBox.Text connection.Password = passwordBox.Text connection.Authority = "ntlmdomain:ms1"
Dim scope As New ManagementScope( _
"\\ms1\root\CIMV2", connection)
scope.Connect()
Dim query As New ObjectQuery( _
"SELECT * FROM Win32_DiskDrive")
Dim searcher As New ManagementObjectSearcher(scope, query)
For Each queryObj As ManagementObject in searcher.Get()
Console.WriteLine("-----------------------------------")
Console.WriteLine("Win32_DiskDrive instance")
Console.WriteLine("-----------------------------------")
Console.WriteLine("Caption: {0}", queryObj("Caption"))
Next
它正确列出了我正在查询的服务器中的 5 个硬盘。
但是当我在 asp.net (vb) 中执行它时,它只列出了 1 个驱动器。
Dim query4 As New ObjectQuery("Select * from Win32_DiskDrive")
Dim searcher4 As New ManagementObjectSearcher(scope, query4)
For Each queryObj3 As ManagementObject In searcher4.Get()
'Availability
' text15.Text = queryObj3("Name")
text16.Text = queryObj3("Caption")
Next
我的结果绑定到一个文本字段,格式化为换行和多行。
问候
路易斯·范鲁扬