如何解决列出我周围的所有wifi
我刚刚开始vbs,所以我是新手。我需要帮助以尝试显示我周围所有可用的wifi网络。我正在尝试将其全部放入一个msgBox中。到目前为止,这是我的代码。
Set objShell = CreateObject("Wscript.Shell")
strCommand = "netsh wlan show network mode=bssid "
Set objExecObject = objShell.Exec(strCommand)
Do While Not objExecObject.StdOut.AtEndOfStream
strText = objExecObject.StdOut.ReadAll()
Loop
Wscript.Echo strText
它对我来说很好,只是我无法在一个msgbox中看到所有的wifi名称。它在中间被切开。另外,请确保脚本在vbscript中。它不能在HTA中进行。有谁能够帮助我?谢谢!
解决方法
您可以执行类似的操作,将数据结果保存到文本文件而不是MsgBox中:
Set objShell = CreateObject("Wscript.Shell")
strCommand = "cmd /c netsh wlan show network mode=bssid>%Appdata%\BSSID.txt & start /MAX Notepad %Appdata%\BSSID.txt"
objShell.Run strCommand,True
编辑:09/11/2020
您可以尝试以下vbscript:
Const ForReading = 1
Set objShell = CreateObject("Wscript.Shell")
strCommand = "cmd /c netsh wlan show network mode=bssid>%Appdata%\BSSID.txt"
objShell.Run strCommand,True
ResultFile = objShell.ExpandEnvironmentStrings("%Appdata%\BSSID.txt")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile(ResultFile,ForReading)
strText = ObjFile.ReadAll
arrLines = Split(strText,vbCrlf)
Set oReg = New RegExp
With oReg
.Global = True
.Pattern = "\r\n" 'vbCrLf
lCount = .Execute(strText).Count + 1
End With
'WScript.Echo lCount
For i = 4 to lCount/2 + 2
M1 = M1 + arrLines(i) & vbcrlf
Next
For i = lCount/2 + 2 to lCount - 1
M2 = M2 + arrLines(i) & vbcrlf
Next
wscript.echo M1
wscript.echo M2
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。