在excel中,我试图获取所有可用无线连接的列表,并将它们列在Excel电子表格中。我已经完成了,并且能够使用以下代码找到我的无线适配器,但是我想看到来自该适配器的所有可用连接,我不知道从哪里开始:
strComputer = "."
Set objWMIService = GetObject( _
"winmgmts:\\" & strComputer & "\root\cimv2")
Set colNetCards = objWMIService.ExecQuery _
("Select * From Win32_NetworkAdapterConfiguration ")
For Each objNetCard In colNetCards
ActiveCell.FormulaR1C1 = objNetCard.Description
ActiveCell.Offset(0, 1).Select
If 0 < InStr(objNetCard.Description, "Wireless") Then
ActiveCell.FormulaR1C1 = "Found It!!!"
Else
ActiveCell.FormulaR1C1 = "Not Found"
End If
我不知道我是否走在正确的轨道上,或者我的方向错了,但任何帮助都会受到赞赏......谢谢
最后澄清一下,如果我愿意的话,我想要的列表会显示我可以连接到的可用SSID。
答案 0 :(得分:1)
我找到了一种使用netsh命令的方法,并且能够从以下代码中获得我想要的结果......
Dim strNetwork As String
strNetwork = ShellRun("netsh wlan show network")
Public Function ShellRun(sCmd As String) As String
'Run a shell command, returning the output as a string'
Dim oShell As Object
Set oShell = CreateObject("WScript.Shell")
'run command'
Dim oExec As Object
Dim oOutput As Object
Set oExec = oShell.Exec(sCmd)
Set oOutput = oExec.StdOut
'handle the results as they are written to and read from the StdOut object'
Dim s As String
Dim sLine As String
While Not oOutput.AtEndOfStream
sLine = oOutput.ReadLine
If sLine <> "" Then s = s & sLine & vbCrLf
Wend
ShellRun = s
End Function
希望这有助于未来的任何人尝试为这样的事情提出解决方案。