Announcement

Collapse
No announcement yet.

Port scan

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Port scan

    Hi all, as I am installing an app that needs connection through TCP port I need to check whether the TCP port is already used. Is there a way to check whether the port number is used or not. Lets say I want to test whether the port 8443 is used by any other application, how would I do that through NSIS installer during installation.

  • #2
    You'd probably need to launch a third-party tcp ping or tcptrace mate, using Exec, ExecWait, or nsExec::Exec (look those up in the docs for details). Far as I know there's no plugin written to do that stuff, feel free to write one yourself

    Comment


    • #3
      It's easy to get all used ports list, for example 'netstat -a' using nsExec or attached plug-in (re-worked not long ago ), but '|grep 8443' not works on most of Wins, so you will need to learn NSIS string and file functions to extract 8443 LISTENING string.
      Attached Files

      Comment


      • #4
        Ok how will I get the output of netstat -a command

        I have tried the following:

        ExecWait "netstat -a" $0

        This did not work

        Comment


        • #5
          Originally posted by bgosalci
          Ok how will I get the output of netstat -a command

          I have tried the following:

          ExecWait "netstat -a" $0

          This did not work
          Hi,

          I would recommand the nsExec plug-in like so:

          nsExec::ExecToStack '"netstat" -a'
          Pop $0

          from the nsExec documentation: "...ExecToStack will push up to ${NSIS_MAX_STRLEN} characters of output onto the stack after the return value."

          Hope this helps,

          KenA

          Comment


          • #6
            Thanks for reply but the value returned is = 0.

            if used with timeout the returned value is = error.

            Comment


            • #7
              Originally posted by bgosalci
              Thanks for reply but the value returned is = 0.

              if used with timeout the returned value is = error.
              My bad, here's what should work.

              nsExec::ExecToStack /TIMEOUT=5000 '"netstat.exe" -a'
              Pop $0 ; retrieve the error code
              StrCmp $0 "0" 0 not_ok
              Pop $0 ; retrieve the output.
              not_ok: ;error dealing code...
              ...

              Should be better.

              KenA

              Comment


              • #8
                config.h(11):#define NSIS_MAX_STRLEN 1024
                but I see few screens of data on netstat, exec 2log looks better for me.

                Comment


                • #9
                  I have found a utility that runs in Windows command line, which will do the work. If any one else needs this sort of utility than check the links.

                  Download:


                  Info:
                  Microsoft support is here to help you with Microsoft products. Find how-to articles, videos, and training for Microsoft 365, Windows, Surface, and more.

                  Comment

                  Working...
                  X