Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to redirect the output of netstat to a file and it doesn't work.

Initially I tried:

runas /noprofile /user:xxxxx\administrator "netstat -a -b > C:\temp\file.txt"

Then I read somewhere that the output of netstat is sent to std.err:

runas /noprofile /user:xxxxx\administrator "netstat -a -b 2>C:\temp\file.txt"

I've also tried it this way:

runas /noprofile /user:xxxxx\administrator "netstat -ab 2> C:\temp\file.txt"

None of these seem to result in the file C:\temp\file.txt being populated with the output.

share|improve this question
Please post your solution as an answer and accept it. – terdon Feb 7 '13 at 16:10
actually using 1> instead only worked on my machine, not on the user's machine. :-p – leeand00 Feb 7 '13 at 16:21
Is the C:\temp\file.txt created by any or all of the above commands, with nothing written to it? Does the output of the netstat command appear on the screen (or anywhere else)? Have you tried this with a simple command, like dir, date /t, hostname, or ping – Scott Feb 7 '13 at 20:24
up vote 2 down vote accepted

I suggest trying:

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

i.e., redirect the output of the runas command (which should encompass the output of the netstat command) rather than redirecting the output of the netstat command directly.

share|improve this answer

From an elevated command prompt use the following:

netstat -a -b > C:\netstat.txt
share|improve this answer
Please read the question again carefully. Your answer does not answer the original question. – DavidPostill Jul 13 at 20:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .