2016-12-04 13 views
1

デバイスの範囲内でWiFiネットワークを出力するこのコマンドを実行し、すべてのネットワークを変数iとして保存するこれまでにわかっていることはこれです:コマンドからコンソール出力を記録し、それを変数として変数に保存したい

Dim networks 
set oShell = createobject("wscript.shell") 
oShell.run "cmd.exe /C netsh wlan show profiles" 

しかし、私はそれを記録するいくつかの方法が必要ですが、私は任意のヘルプははるかに高く評価されるだろうか、知らないunfortunatley

答えて

0

あなたの問題は.Runメソッドがアクセス権を与えないということです実行されたプログラムの出力。 Execメソッドを使用し、StdOutプロパティからプログラムの出力を取得する必要があります。

Option Explicit 

Dim shell, executed, buffer 

    rem Instantiate the needed component to launch another executable 
    Set shell = WScript.CreateObject("WScript.Shell") 

    rem If you expect a lot of data from the output of the command 
    rem or if you need separate lines 
    Set executed = shell.Exec("netsh wlan show profiles") 
    Do While Not executed.StdOut.AtEndOfStream 
     buffer = executed.StdOut.ReadLine() 
     Call WScript.Echo(buffer) 
    Loop 

    rem For short outputs, you can retrieve all the data in one call 
    Set executed = shell.Exec("netsh wlan show profiles") 
    buffer = executed.StdOut.ReadAll() 
    Call WScript.Echo(buffer) 
関連する問題