列出我周围所有的wifi

List all the wifi around me

我才刚刚开始使用 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

它对我来说很好,只是我无法在一个消息框中看到所有的 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,0,True

编辑:2020 年 9 月 11 日

你可以试试这个 vbscript :

Const ForReading = 1
Set objShell = CreateObject("Wscript.Shell")
strCommand = "cmd /c netsh wlan show network mode=bssid>%Appdata%\BSSID.txt"
objShell.Run strCommand,0,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