|
|
#1 |
|
Member
Join Date: Jul 2015
Posts: 62
|
Check if Port is open
Hi All,
I am trying to use this in my installer to see if a port is open. I need to show a message box if the port cannot be used or proceed if its ok to use the port. http://nsis.sourceforge.net/Check_open_ports I am not able to figure out the example in this page. If I used the condition with {If}, how would this be: ${If} ${TCPPortOpen} $PortNumber MessageBox MB_OK|MB_ICONSTOP "$PortNumber is already using by another program..." Abort ${Else} MessageBox MB_OK"$PortNumber is open to use" Is this correct? |
|
|
|
|
|
#2 |
|
Moderator
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,442
|
Looks OK to me. What happens when you run your installer?
IntOp $PostCount $PostCount + 1 |
|
|
|
|
|
#3 |
|
Member
Join Date: Jul 2015
Posts: 62
|
The installation proceeds no matter what port I give. Is there any port on my Windows machine I can specify where this check will fail and abort?
|
|
|
|
|
|
#4 |
|
Major Dude
Join Date: May 2005
Location: New Zealand
Posts: 916
|
There should be an ${EndIf} at the end of that code. Do you get any warnings when you compile the script?
"Only a MouseHelmet will save you from a MouseTrap" -Jason Ross (Me) NSIS 3 POSIX Ninja Wiki Profile |
|
|
|
|
|
#5 |
|
Member
Join Date: Jul 2015
Posts: 62
|
Hi Jason,
Yes I do have a ${EndIf}, didnt post the whole snippet, here it is: ${If} ${TCPPortOpen} $PortNumber MessageBox MB_OK|MB_ICONSTOP "$PortNumber is already using by another program..." Abort ${Else} MessageBox MB_OK "$PortNumber is open to use" ${EndIf} what I don't get is , if the Port is open as per this line below, ${If} ${TCPPortOpen} $PortNumber Doesn't this mean that the port is OK to use and proceed with the install? |
|
|
|
|
|
#6 |
|
Moderator
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,442
|
Open probably means some application is using it. I don't understand how this can be so hard to test, since you are checking for ports I assume you have some application that opens a port so you can just run it and test your installer. You can also use netstat or download TCPView to find open ports on your machine...
IntOp $PostCount $PostCount + 1 |
|
|
|
|
|
#7 |
|
Member
Join Date: Jul 2015
Posts: 62
|
Thanks Anders. My understanding was "TCPPortOpen" meant an "Open" port which one could use, sorry for the confusion. I did verify that the code is working by entering a port which was in use by the application.
Thank you everyone for the inputs. |
|
|
|
![]() |
|
|||||||
| Thread Tools | Search this Thread |
| Display Modes | |
|
|