How to use WMIC to connect to remote machine and output netstat to a file?

50,713

When issuing remote commands, quote the entire string to execute, like:

wmic /node:remote_computer process call create "netstat.exe -ano > C:\output.txt"
Share:
50,713
coddrego
Author by

coddrego

Updated on September 18, 2022

Comments

  • coddrego
    coddrego almost 2 years

    I'm trying to issue the following command remotely:

    netstat -ano > C:\output.txt

    but cannot figure out how to do that with WMIC! Any idea?

    I've got:

    process call create netstat.exe 
    

    working but I cannot figure out how to pass the -ANO nor the output. Help please :)

  • songei2f
    songei2f almost 13 years
    You probably need to add a /output:stdout because it does not do this by default if you want the file on the remote computer (that is ambiguous in your question), or it will be a useless output file. It took me a long time with wmic to figure that out.
  • coddrego
    coddrego almost 13 years
    To add to the question, id like the output to be redirected to the remote machine (the issuer). Thanks!
  • kasperd
    kasperd over 9 years
    This answer is not very useful without an explanation of what it is doing.
  • Patrick Mevzek
    Patrick Mevzek over 6 years
    Please a least give one example in your answer as text instead of just an URL.
  • Paul
    Paul over 6 years
    Welcome to Server Fault! Your answer suggests a workable solution to the question is available via another website. The Stack Exchange family of Q&A websites generally frowns on this type of answer. Please read How do I write a good answer? and consider revising your answer to include the steps required to resolve the issue. And don't forget to take the site tour.