Reputation: 190
I have barely started vbs so I am new. I need help trying to show all wifi networks available around me. I am trying to fit it all in one msgBox. Here is my code so far.
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
It works fine for me just I can't see all the wifi names in one msgbox. It gets cut in the middle. Also, please make sure the script is in vbscript. It can not be make in HTA. Can anybody help me? Thank you!
Upvotes: 1
Views: 641
Reputation: 18827
You can do something like that save the data results into text file instead of 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
EDIT : 09/11/2020
You can give a try for this 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
Upvotes: 2