Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

IP Address

19 REPLIES 19
Reply
Message 1 of 20
Anonymous
1550 Views, 19 Replies

IP Address

hello all

is there a way to get the ip address
of a computer thru the registry
programatically (no dos-lib please)

TIA
mark
19 REPLIES 19
Message 2 of 20
Anonymous
in reply to: Anonymous

Mark,

I would hope not. That would be scary. -David

Mark wrote:

> hello all
>
> is there a way to get the ip address
> of a computer thru the registry
> programatically (no dos-lib please)
>
> TIA
> mark
>
>
Message 3 of 20
Anonymous
in reply to: Anonymous

(command "sh" "ipconfig>c:\\ip.txt")
Then search the resulting file.



"Mark" wrote in message
news:B93E4EAF0F0DE5EC9AB7A2D6D5E56410@in.WebX.maYIadrTaRb...
>
> hello all
>
> is there a way to get the ip address
> of a computer thru the registry
> programatically (no dos-lib please)
>
> TIA
> mark
>
>
Message 4 of 20
Anonymous
in reply to: Anonymous

I was actually doing just that for this...
Ha! Great minds think alike... (And so do we...)


"F. Gump" wrote in message
news:C0C441CEA78750EE2D6CBD784C24EB94@in.WebX.maYIadrTaRb...
> (command "sh" "ipconfig>c:\\ip.txt")
> Then search the resulting file.
>
>
>
> "Mark" wrote in message
> news:B93E4EAF0F0DE5EC9AB7A2D6D5E56410@in.WebX.maYIadrTaRb...
> >
> > hello all
> >
> > is there a way to get the ip address
> > of a computer thru the registry
> > programatically (no dos-lib please)
> >
> > TIA
> > mark
> >
> >
>
>
Message 5 of 20
Anonymous
in reply to: Anonymous

This also worked for me...
But I'm sure it would be different for different network set-ups...
We use DHCP to hand out addresses & I'm running Win2K.

;;############### Begin GetIP.lsp ###############
(defun getIP ( / Reg-Key ipAddy)

(setq Reg-Key (strcat
"HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\"
(car (vl-registry-descendents
"HKEY_LOCAL_MACHINE\\SYSTEM\\ControlSet001\\Services\\"))
"\\Parameters\\Tcpip") )

(setq ipAddy (vl-registry-read Reg-Key "DhcpIPAddress"))

ipAddy
)

;;############### End GetIP.lsp ###############


"Thomas Smith" wrote in message
news:31EA82110B8209D101CC4D297452DF35@in.WebX.maYIadrTaRb...
> I was actually doing just that for this...
> Ha! Great minds think alike... (And so do we...)
>
>
> "F. Gump" wrote in message
> news:C0C441CEA78750EE2D6CBD784C24EB94@in.WebX.maYIadrTaRb...
> > (command "sh" "ipconfig>c:\\ip.txt")
> > Then search the resulting file.
> >
> >
> >
> > "Mark" wrote in message
> > news:B93E4EAF0F0DE5EC9AB7A2D6D5E56410@in.WebX.maYIadrTaRb...
> > >
> > > hello all
> > >
> > > is there a way to get the ip address
> > > of a computer thru the registry
> > > programatically (no dos-lib please)
> > >
> > > TIA
> > > mark
> > >
> > >
> >
> >
>
>


----------------------------------------------------------------------------
----


(defun getIP ( / tmpFile rf ipAddy startTime delay)

(setq tmpFile "c:\\IPinfo.txt")
(command "shell" (strcat "ipconfig > \"" tmpFile "\""))

(setq startTime (* (distof (rtos (getvar "date") 2 15)) 1000000000))
(setq delay 10000)
; 10000 = 1 second...
; This delay is neccesary to wait for the system commands to complete.
; You may need to adjust it up on slower machines.
; If you know it'll be running on faster machines, you may be able to
decrease it.

(while (not (> (- (* (distof (rtos (getvar "date") 2 15)) 1000000000)
startTime) delay))
(princ "\r|")
(princ "\r/")
(princ "\r-")
(princ "\r\\"))

(setq rf (open tmpFile "r"))

(repeat 11
(read-line rf))
(setq ipAddy (substr (read-line rf) 38))
(close rf)

(command "shell" (strcat "del \"" tmpFile "\""))

ipAddy
)
Message 6 of 20
Anonymous
in reply to: Anonymous

Nice, but it doesn't work for me since Im static.


"Thomas Smith" wrote in message
news:1D113EAF8CB879ABAB913D454BF90A12@in.WebX.maYIadrTaRb...
> This also worked for me...
> But I'm sure it would be different for different network set-ups...
> We use DHCP to hand out addresses & I'm running Win2K.
>
> ;;############### Begin GetIP.lsp ###############
> (defun getIP ( / Reg-Key ipAddy)
>
> (setq Reg-Key (strcat
> "HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\"
> (car (vl-registry-descendents
> "HKEY_LOCAL_MACHINE\\SYSTEM\\ControlSet001\\Services\\"))
> "\\Parameters\\Tcpip") )
>
> (setq ipAddy (vl-registry-read Reg-Key "DhcpIPAddress"))
>
> ipAddy
> )
>
> ;;############### End GetIP.lsp ###############
>
>
> "Thomas Smith" wrote in message
> news:31EA82110B8209D101CC4D297452DF35@in.WebX.maYIadrTaRb...
> > I was actually doing just that for this...
> > Ha! Great minds think alike... (And so do we...)
> >
> >
> > "F. Gump" wrote in message
> > news:C0C441CEA78750EE2D6CBD784C24EB94@in.WebX.maYIadrTaRb...
> > > (command "sh" "ipconfig>c:\\ip.txt")
> > > Then search the resulting file.
> > >
> > >
> > >
> > > "Mark" wrote in message
> > > news:B93E4EAF0F0DE5EC9AB7A2D6D5E56410@in.WebX.maYIadrTaRb...
> > > >
> > > > hello all
> > > >
> > > > is there a way to get the ip address
> > > > of a computer thru the registry
> > > > programatically (no dos-lib please)
> > > >
> > > > TIA
> > > > mark
> > > >
> > > >
> > >
> > >
> >
> >
>
>
> --------------------------------------------------------------------------
--
> ----
>
>
> (defun getIP ( / tmpFile rf ipAddy startTime delay)
>
> (setq tmpFile "c:\\IPinfo.txt")
> (command "shell" (strcat "ipconfig > \"" tmpFile "\""))
>
> (setq startTime (* (distof (rtos (getvar "date") 2 15)) 1000000000))
> (setq delay 10000)
> ; 10000 = 1 second...
> ; This delay is neccesary to wait for the system commands to complete.
> ; You may need to adjust it up on slower machines.
> ; If you know it'll be running on faster machines, you may be able to
> decrease it.
>
> (while (not (> (- (* (distof (rtos (getvar "date") 2 15)) 1000000000)
> startTime) delay))
> (princ "\r|")
> (princ "\r/")
> (princ "\r-")
> (princ "\r\\"))
>
> (setq rf (open tmpFile "r"))
>
> (repeat 11
> (read-line rf))
> (setq ipAddy (substr (read-line rf) 38))
> (close rf)
>
> (command "shell" (strcat "del \"" tmpFile "\""))
>
> ipAddy
> )
>
>
>
Message 7 of 20
Anonymous
in reply to: Anonymous

Do a quick search through your registry to see if you can find your IP
Address...
That's what I did to find mine...

See if it exists in the
"HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\"
key somewhere...

If it does, just modify what Ive got there to work for you.

"F. Gump" wrote in message
news:D28B2A16C25F6A58269EE974AEB43DF1@in.WebX.maYIadrTaRb...
> Nice, but it doesn't work for me since Im static.
>
>
> "Thomas Smith" wrote in message
> news:1D113EAF8CB879ABAB913D454BF90A12@in.WebX.maYIadrTaRb...
> > This also worked for me...
> > But I'm sure it would be different for different network set-ups...
> > We use DHCP to hand out addresses & I'm running Win2K.
> >
> > ;;############### Begin GetIP.lsp ###############
> > (defun getIP ( / Reg-Key ipAddy)
> >
> > (setq Reg-Key (strcat
> > "HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\"
> > (car (vl-registry-descendents
> > "HKEY_LOCAL_MACHINE\\SYSTEM\\ControlSet001\\Services\\"))
> > "\\Parameters\\Tcpip") )
> >
> > (setq ipAddy (vl-registry-read Reg-Key "DhcpIPAddress"))
> >
> > ipAddy
> > )
> >
> > ;;############### End GetIP.lsp ###############
> >
> >
> > "Thomas Smith" wrote in message
> > news:31EA82110B8209D101CC4D297452DF35@in.WebX.maYIadrTaRb...
> > > I was actually doing just that for this...
> > > Ha! Great minds think alike... (And so do we...)
> > >
> > >
> > > "F. Gump" wrote in message
> > > news:C0C441CEA78750EE2D6CBD784C24EB94@in.WebX.maYIadrTaRb...
> > > > (command "sh" "ipconfig>c:\\ip.txt")
> > > > Then search the resulting file.
> > > >
> > > >
> > > >
> > > > "Mark" wrote in message
> > > > news:B93E4EAF0F0DE5EC9AB7A2D6D5E56410@in.WebX.maYIadrTaRb...
> > > > >
> > > > > hello all
> > > > >
> > > > > is there a way to get the ip address
> > > > > of a computer thru the registry
> > > > > programatically (no dos-lib please)
> > > > >
> > > > > TIA
> > > > > mark
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >
> >
> >
>
> --------------------------------------------------------------------------
> --
> > ----
> >
> >
> > (defun getIP ( / tmpFile rf ipAddy startTime delay)
> >
> > (setq tmpFile "c:\\IPinfo.txt")
> > (command "shell" (strcat "ipconfig > \"" tmpFile "\""))
> >
> > (setq startTime (* (distof (rtos (getvar "date") 2 15)) 1000000000))
> > (setq delay 10000)
> > ; 10000 = 1 second...
> > ; This delay is neccesary to wait for the system commands to complete.
> > ; You may need to adjust it up on slower machines.
> > ; If you know it'll be running on faster machines, you may be able to
> > decrease it.
> >
> > (while (not (> (- (* (distof (rtos (getvar "date") 2 15)) 1000000000)
> > startTime) delay))
> > (princ "\r|")
> > (princ "\r/")
> > (princ "\r-")
> > (princ "\r\\"))
> >
> > (setq rf (open tmpFile "r"))
> >
> > (repeat 11
> > (read-line rf))
> > (setq ipAddy (substr (read-line rf) 38))
> > (close rf)
> >
> > (command "shell" (strcat "del \"" tmpFile "\""))
> >
> > ipAddy
> > )
> >
> >
> >
>
>
Message 8 of 20
Anonymous
in reply to: Anonymous

thanks guys

"Mark" wrote in message news:B93E4EAF0F0DE5EC9AB7A2D6D5E56410@in.WebX.maYIadrTaRb...
>
> hello all
>
> is there a way to get the ip address
> of a computer thru the registry
> programatically (no dos-lib please)
>
> TIA
> mark
>
>
Message 9 of 20
Anonymous
in reply to: Anonymous

with your help i was able to create this code,
can anybody in this ng check if it
works with any os/ system with a network card,
also how to tell which, if there are multiple cards
thanks

(defun C:GIP (/ rkey)
(setq rkey
"HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters\\Interfaces\\")
(cadr (vl-registry-read (strcat rkey (car (vl-registry-descendents rkey))) "IpAddress")) )


"Mark" wrote in message news:B93E4EAF0F0DE5EC9AB7A2D6D5E56410@in.WebX.maYIadrTaRb...
>
> hello all
>
> is there a way to get the ip address
> of a computer thru the registry
> programatically (no dos-lib please)
>
> TIA
> mark
>
>
Message 10 of 20
Anonymous
in reply to: Anonymous

"Mark" wrote:
>
> with your help i was able to create this code,
> can anybody in this ng check if it
> works with any os/ system with a network card,
> also how to tell which, if there are multiple cards
> thanks
>
> snip <

On Win2000 Pro I got:

Command: gip
"0.0.0.0"

Which doesn't seem too useful. Not real sure about our setup though.

Have fun,
Dave
Message 11 of 20
Anonymous
in reply to: Anonymous

Sorry about that name thingy...

HAve fun,
Dave
Message 12 of 20
Anonymous
in reply to: Anonymous

This Value will only work for statis IP addresses...
The Value I used is for dynamic addresses...
You might want to check & see if it's 0.0.0.0 & read the other one...
Try this...
Let me know if it works for you...
It returns my DhcpIPAddress...

(defun C:GIP (/ rkey ipAddy)
(setq rkey
"HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters\
\Interfaces\\")
(if (= (setq ipAddy (cadr (vl-registry-read (strcat rkey (car
(vl-registry-descendents rkey))) "IpAddress"))) "0.0.0.0")
(vl-registry-read (strcat rkey (car (vl-registry-descendents rkey)))
"DhcpIPAddress")
ipAddy)
)





"Mark" wrote in message
news:21DC7D603584486D6DFEAB172E7A76EC@in.WebX.maYIadrTaRb...
>
> with your help i was able to create this code,
> can anybody in this ng check if it
> works with any os/ system with a network card,
> also how to tell which, if there are multiple cards
> thanks
>
> (defun C:GIP (/ rkey)
> (setq rkey
>
"HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters\
\Interfaces\\")
> (cadr (vl-registry-read (strcat rkey (car (vl-registry-descendents
rkey))) "IpAddress")) )
>
>
> "Mark" wrote in message
news:B93E4EAF0F0DE5EC9AB7A2D6D5E56410@in.WebX.maYIadrTaRb...
> >
> > hello all
> >
> > is there a way to get the ip address
> > of a computer thru the registry
> > programatically (no dos-lib please)
> >
> > TIA
> > mark
> >
> >
>
>
Message 13 of 20
Anonymous
in reply to: Anonymous

Command: gip
; error: bad argument type: stringp nil


hAVE FUN,
dAVE

"Thomas Smith" wrote:
> SNIP <
> Try this...
> Let me know if it works for you...
> It returns my DhcpIPAddress...
>
> SNIP <
Message 14 of 20
Anonymous
in reply to: Anonymous

It wasn't a code problem... It's a formatting problem...
The newsgroup reformatted my text...

See the attachment to load it the way I wrote it.

Sorry about that.


"DaveS" wrote in message
news:E45ECB2751C850A69EF23AE1CCC690BE@in.WebX.maYIadrTaRb...
> Command: gip
> ; error: bad argument type: stringp nil
>
>
> hAVE FUN,
> dAVE
>
> "Thomas Smith" wrote:
> > SNIP <
> > Try this...
> > Let me know if it works for you...
> > It returns my DhcpIPAddress...
> >
> > SNIP <
>
>
Message 15 of 20
Anonymous
in reply to: Anonymous

"Thomas Smith" wrote:
> It wasn't a code problem... It's a formatting problem...
> The newsgroup reformatted my text...
>
> See the attachment to load it the way I wrote it.
>
> Sorry about that.
>
>
> sinp <

I had to reverse this list before it would work here. Like this:

(car (reverse (vl-registry-descendents rkey)))


Have fun,
Dave
Message 16 of 20
Anonymous
in reply to: Anonymous

Hm...
That would seem to mean that the registry structure isn't exactly the same
there...
I know that the key we're grabbing there won't be the same for everyone, so
we're probably looking at something a little more complicated to get it...
Give me a little bit to find a few spare minutes to write it up...
Done...

Give this one a try...
It'a a little conveluded, but it should work for you... (I hope)...
I'm taking a few assumptions with this one...
I've got multiple entries under the "interfaces" key & I'm assuming that
the Ethernet connection always has a value for
"IPAutoconfigurationAddress"...
Another problem with this is if the PC has multiple Ethernet cards, this
will only
catch one of them...

Anyhow, assuming I'm right on the above assumption this would cover
MOST people's set-ups.

Let me know if this doesn't work for you.

Thomas

"DaveS" wrote in message
news:969EB77369D8CAFFD2C755E2399E028B@in.WebX.maYIadrTaRb...
>
> I had to reverse this list before it would work here. Like this:
>
> (car (reverse (vl-registry-descendents rkey)))
> snip<
Message 17 of 20
Anonymous
in reply to: Anonymous

works for me.

"Thomas Smith" wrote in message
news:A4EF0461E498F6E0B6945AD6F7B70148@in.WebX.maYIadrTaRb...
> Hm...
> That would seem to mean that the registry structure isn't exactly the same
> there...
> I know that the key we're grabbing there won't be the same for everyone,
so
> we're probably looking at something a little more complicated to get it...
> Give me a little bit to find a few spare minutes to write it up...
> Done...
>
> Give this one a try...
> It'a a little conveluded, but it should work for you... (I hope)...
> I'm taking a few assumptions with this one...
> I've got multiple entries under the "interfaces" key & I'm assuming that
> the Ethernet connection always has a value for
> "IPAutoconfigurationAddress"...
> Another problem with this is if the PC has multiple Ethernet cards, this
> will only
> catch one of them...
>
> Anyhow, assuming I'm right on the above assumption this would cover
> MOST people's set-ups.
>
> Let me know if this doesn't work for you.
>
> Thomas
>
> "DaveS" wrote in message
> news:969EB77369D8CAFFD2C755E2399E028B@in.WebX.maYIadrTaRb...
> >
> > I had to reverse this list before it would work here. Like this:
> >
> > (car (reverse (vl-registry-descendents rkey)))
> > snip<
>
>


----------------------------------------------------------------------------
----




(defun C:GIP (/)
(setq rkey
"HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters\
\Interfaces\\")
(setq keyList (vl-registry-descendents rkey))

(setq tmpInt (length keyList))
(setq ipAddy nil)
(while (and (>= (setq tmpInt (1- tmpInt)) 0) (not ipAddy))
(setq tmpKey (strcat rkey (nth tmpInt keyList)))
(setq tmpValue (vl-registry-read tmpKey "IPAutoconfigurationAddress"))
(if tmpValue
(if (wcmatch tmpValue "*\.*\.*\.*")
(setq ipAddy (cadr (vl-registry-read tmpKey "IPAddress"))))))

(if (not ipAddy)
(progn
(alert "Couldn't find an Ethernet connection with an assigned IP
address!")
(exit)))

(if (= ipAddy "0.0.0.0")
(setq ipAddy (vl-registry-read tmpKey "DhcpIpAddress"))
ipAddy)
)
Message 18 of 20
Anonymous
in reply to: Anonymous

Looks like a winner!! :O)

Have fun,
Dave
Message 19 of 20
Anonymous
in reply to: Anonymous

yeah!!!


"DaveS" wrote in message
news:f1a535a.16@WebX.maYIadrTaRb...
> Looks like a winner!! :O)
>
> Have fun,
> Dave
>
>
Message 20 of 20
scotts
in reply to: Anonymous

Hi there!

 

So I'm using this same bit of script and it works like a charm for XP installs, but Windows 7 not so good.  It seems like it should work, but no go...  I tried browsing around to find an alternate solution but so far have been unsuccessful.  Any ideas?

 

-Scott

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost