
我試圖將 的輸出重定向netstat
到文件,但它不起作用。
最初我嘗試過:
runas /noprofile /user:xxxxx\administrator "netstat -a -b > C:\temp\file.txt"
然後我在某處讀到 netstat 的輸出被送到 std.err:
runas /noprofile /user:xxxxx\administrator "netstat -a -b 2>C:\temp\file.txt"
我也試過這樣:
runas /noprofile /user:xxxxx\administrator "netstat -ab 2> C:\temp\file.txt"
這些似乎都不會導致文件C:\temp\file.txt
被輸出填滿。
答案1
我建議嘗試:
runas /noprofile /user:xxxxx\administrator "netstat -a -b" > C:\temp\file.txt
或者:
runas /noprofile /user:xxxxx\administrator "netstat -a -b" 2> C:\temp\file.txt
即,重定向指令的輸出runas
(應該包含指令的輸出),而不是直接netstat
重定向指令的輸出。netstat
答案2
來自一個提升的命令提示符使用以下內容:
netstat -a -b > C:\netstat.txt