你的問題是,.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)