Announcement

Collapse
No announcement yet.

Couple of newbie questions

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

  • Couple of newbie questions

    Hi all, I have a couple of questions:

    1. When I use Exec and ExecWait - what is their default directory if I don't specify an absolute path (as far as I could see it isn't $OUTDIR)

    2. Is there an existing way in NSIS 1.98 to detect the computer's IP address, or can anyone think of an easy way to parse "ipconfig"'s output into a variable?

    Thanks!

  • #2
    1) the currentdir, so $EXEDIR. The current dir becomes $OUTDIR if SetOutPath has been called.

    2) not available in NSIS 1.98. But you can log the output of ipconfig to file using "ipconfig > ip.txt" and then analyse the file. Remember that the structure of this file depends on the setup of the network/internet connection and on the language of the system. So it's difficult to get the ipaddress (for internetconnection, not network connection) from this.
    I will write a NSISdll for it. Wait a sec...

    -Hendri.

    Comment


    • #3
      Here's a dll to retrieve the IP-addresses of a computer. I just copied code from some website (and modified it to suit our needs). This code also retrieves IP-addresses of a computer on a network. I wouldn't know how to distinguish these from internet IP-addresses. But it works already. See the attachment.

      Good luck,
      -Hendri.

      [edit]
      Searching also resulted in this thread:
      http://forums.winamp.com/showthread....6&highlight=ip also states what I discussed above. Best solution there: use ipconfig or a dll . Good luck with the dll.
      -Hn3.
      [/edit]
      Attached Files

      Comment


      • #4
        This is great, thanks!

        Comment


        • #5
          You're welcome .

          Greetz,
          -Hendri.

          Comment


          • #6
            I rescripted the function a bit to allow for a better integration of the IP.dll in new scripts. Check the source.

            [edit]
            A tiny test on a stand-alone (not connected to this world) showed that the dll returned IP-address 127.0.0.1. Maybe this could be the hint from which we can conclude that there is no connection. Sincerely, I do not know that much about (assigning) IP-addresses. I know how to set up a small local network but beyond that, I cannot help. Good luck!
            -Hn3.
            [/edit]

            Have fun, good luck,
            -Hendri.
            Attached Files

            Comment


            • #7
              Originally posted by Smile2Me
              This code also retrieves IP-addresses of a computer on a network. I wouldn't know how to distinguish these from internet IP-addresses. But it works already. See the attachment.
              These ranges are for local networks:

              10.x.x.x / 255.0.0.0
              172.16.x.x / 255.255.0.0 to 172.31.x.x / 255.255.0.0
              192.168.x.x / 255.255.255.0
              169.254.x.x / 255.255.0.0

              Comment


              • #8
                Thanks a lot Joost,

                see the function I scripted using your information. Now the script provides two functions:
                GetNextIp
                CheckIP

                [Important edit]
                I added the rangecheck 127.x.x.x. I found additional information on this (German) site about "LoopBack" addresses. Important: the range 169.254.x.x is not mentioned there as being a LAN range. Could you please verify that it indeed is, Joost? Thanks in advance.
                Untill further information, I include it in the range check, since I think I remember seeing 169.254.x.x on a network a long time ago, but I'm not sure of that.
                -Hn3.
                [/edit]

                See the example for more information.

                Have fun, good luck,
                -Hendri.
                Attached Files

                Comment


                • #9
                  Originally posted by Smile2Me
                  Thanks a lot Joost,

                  see the function I scripted using your information. Now the script provides two functions:
                  GetNextIp
                  CheckIP

                  [Important edit]
                  I added the rangecheck 127.x.x.x. I found additional information on this (German) site about "LoopBack" addresses. Important: the range 169.254.x.x is not mentioned there as being a LAN range. Could you please verify that it indeed is, Joost? Thanks in advance.
                  Untill further information, I include it in the range check, since I think I remember seeing 169.254.x.x on a network a long time ago, but I'm not sure of that.
                  -Hn3.
                  [/edit]

                  See the example for more information.

                  Have fun, good luck,
                  -Hendri.
                  127.0.0.1 is just the localhost, so it is not really a network address. 169.254.x.x is an Automatic Private IP Address, which you get when there is no DHCP server available, for example, Windows gives these addresses when you check "Obtain an IP address automatically" and you have no DHCP server.

                  Comment


                  • #10
                    Thanks again Joost.

                    This is the (I think) final version of the script. The function CheckIP checks for the following types of IP-addresses:
                    1 - LoopBack IP (localhost, indicates no connection to a LAN or to the internet). 2 - Automatic Private IP Address (no DHCP server on LAN).
                    3 - Network IP.
                    4 - Internet IP.

                    Have fun again with this, greetz,
                    -Hendri.
                    Attached Files

                    Comment


                    • #11
                      Additional check needed

                      Can you please add a check that parameter is not an IP address? Unfortunately, the current script issues that string 'NOT AN IP ADDRESS' is an internet-type IP.

                      Thanks.
                      Computer Forensics Investigations, Internet Security and Parental Control, - http://belkasoft.com

                      Comment

                      Working...
                      X