2015-12-21 114 views
1

爲什麼當我爲命令插入「netstat -an | find」「LISTENING」「」時,下面的腳本不起作用?VBscript for netstat過濾僅偵聽端口

set sh = CreateObject("Wscript.Shell") 
call GetConnections() 

Function GetConnections() 
    i = 0 
    set shExec = sh.Exec("netstat -an") 
    Do While Not shExec.StdOut.AtEndOfStream 
     Wscript.Echo shExec.StdOut.ReadLine() 
    Loop 
End Function 

謝謝!

回答

2

|(和<,>,>>)由cmd.exe實現。它對任何其他程序都沒有意義。

所以讓cmd.exe運行你的程序。

set shExec = sh.Exec("cmd /c netstat -an|find something") 
+1

這樣做!謝謝! – Tank