[MSDOS] netstat > netstat.txt

Solved
Hello everyone, I have an issue with my MSDOS. Usually, I use these commands to put the NETSTAT info into a text file:

netstat > netstat.txt
netstat -n > netstatn.txt
netstat -a > netstata.txt

But this command hasn't been working for the last two days, why?
Is this command correct? Did I make a mistake? Because I create a BAT with these commands but when I run it, a MSDOS window opens but nothing happens, the text files are not created! Help please

Thank you, have a good evening.
Configuration: Windows XP Internet Explorer 7.0

10 answers

  1. Moderator
    Try perhaps to indicate the file path to find it
    netstat -a > c:\netstat.txt
    --
    a+
    dje-dje
    A good link is worth more than a long speech
    0
    1. Hello.
      I searched for which service might correspond to netstat but actually none.
      It might be a key that's wrong, or your PATH, I don't know!
      The solution while you find something better, I'm giving you mine:
      http://cqgclub.dyndns.org/BDC/telech/netstat.exe
      Normally it's in system32 but since it's also in dllcache, put it somewhere else because it might get replaced. Place it for example in Windows, and if your batch still doesn't work, try:
      %systemroot%\netstat

      Let me know if it works or not. See you later!
      --
      it's hard to make a signature ;)
      0
      1. Thank you for your responses, dje-dje I tried and it doesn't work either arf!

        The problem is that when I go to start>run>netstat it works fine but when I type the command netstat > netstat.txt it doesn't work...

        CH4NCE: what I don't understand is why it worked 2 days ago and now it doesn't work anymore ??

        A+
        0
        1. Yes, it's weird that it suddenly stopped working.
          But netstat works!!!
          The redirection to a file in run, however, doesn’t work.
          Do it from the command interpreter.
          start=>run=>cmd
          type these lines and tell me what works and what doesn't:
          netstat netstat > c:\test type c:\test

          --
          it's hard to make a signature ;)
          0
          1. les 3 fonctions à partir de la console (démarrer>exécuter>cmd)
            0
            1. So your .bat should work!!!
              I'll make one for you, coming up ;)

              --
              it's hard to make a signature ;)
              0
              1. Here you go, take this little batch:
                http://cqgclub.dyndns.org/BDC/telech/netviewer.bat
                You can know the options of netstat by typing
                netstat /?
                in the command interpreter, and you can learn more about how netstat works in this excellent document:
                https://www2.deloitte.com/fr/fr/pages/risque-compliance-et-controle-interne/articles/cyber-academy.html/ressources/breves/min_srv_res_win.html.fr
                Cheers! ;)
                --
                it's hard to make a signature ;)
                0
                1. Moderator
                  I feel like his problem is more related to the redirection in a file than to the command itself.

                  Maybe he could let us know if the result of the command displays correctly (without errors) in DOS at first.
                  Then test if the redirection of another command works (like dir for example)
                  --
                  a+
                  dje-dje
                  A good link is worth more than a long speech
                  0
                2. @dje-djeWell, apparently the command and redirection work:
                  msdos netstat netstat txt#4
                  It's just that the redirection in run works point, same for me.
                  However, I don't know why and I had never thought of doing it.
                  As for his batch not working, I don't see why, unless he couldn't find the file, which is easy to check but since netstat and redirection normally work...
                  See you later ;)
                  --
                  it's hard to make a signature ;)
                  0
                3. Moderator
                  @CH4NCEIndeed, I tested it and it does the same for me.
                  The redirection works in the command prompt but not in start -> Run
                  --
                  a+
                  dje-dje
                  A good link is worth a long speech
                  0
              2. Thank you CH4NCE, your BAT works perfectly :), but I don’t understand why this command is no longer working:

                netstat >> netstat.txt

                Because it used to work very well before... it’s really strange!
                Anyway, thank you CH4NCE :) and thank you dje-dje ;)
                0
                1. Webmaster
                  In the Run dialog, you need to prefix the command with "cmd /k":

                  cmd /k netstat -a > c:\netstata.txt 

                  --
                  Jeff - Wm@Ccm -
                  0
                  1. Oh well, that's not silly, I hadn't thought of that :)
                    However, with cmd /k cmd stays open, it's better to use cmd /C in this situation because it's the file that will be analyzed.
                    cmd /c netstat -a > c:\netstata.txt 

                    --
                    it's hard to create a signature ;)
                    0
                  2. Moderator
                    I didn't know that either: I'll go to bed less stupid ^^
                    --
                    see you+
                    dje-dje
                    A good link is worth more than a long speech
                    0
                2. The netstat.txt file needs to be created and it should be in the current directory.
                  The redirection with > creates the file or deletes the content.
                  The redirection with >> writes from the last line contained in the file.
                  --
                  it's hard to do a signature ;)
                  0