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.
Announcement
Collapse
No announcement yet.
Port scan
Collapse
X
-
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
-
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
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
-
Originally posted by bgosalci
Thanks for reply but the value returned is = 0.
if used with timeout the returned value is = error.
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
-
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:
Comment
Comment