Author Topic: IP address...  (Read 13574 times)

0 Members and 1 Guest are viewing this topic.

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
IP address...
« Reply #15 on: March 05, 2005, 08:56:17 PM »
You mean like this?



I was able to get the ipaddress using wmi but when I tried to write it out to a temp file using the File System Object ... tada. I'm still working on it (i.e. I refuse to be beat by a dumb ol' puter).

Are you trying something similar?

:D
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

Jeff_M

  • King Gator
  • Posts: 4094
  • C3D user & customizer
IP address...
« Reply #16 on: March 05, 2005, 09:06:29 PM »
Over at the autodesk.autocad.customization newsgroup, Thomas Smith posted a small routine that accesses the registry and reports the IP address. It is in a thread entitled, oddly enough, "IP Address" that was started on December 10, 2003. I just tested it on my WinXP Home laptop and it returned the proper value. You might want to look at it. He did post a few attempts, make sure to grab the last one.

I didn't repost it here, as I'm unsure of the legality and/or ethics of doing such a thing.

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
IP address...
« Reply #17 on: March 05, 2005, 09:16:25 PM »
What, and take all the fun out of it?

Genuine thanks Jeff, but I'm having fun researching this -- copying existing code would be snoozeville. There's buckets of free info at MSDN. Just enough to make the task interesting but not wheel inventing.

:D

'Course, my MSDN membership dues weren't cheap.
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
IP address...
« Reply #18 on: March 05, 2005, 09:24:24 PM »
Quote from: MP
You mean like this?
:D


Yep.

I have used the FSO a lot, mainly 'cause of the speed.

I've been able to control my local scanner enviromment no problems, but a couple of my clients have had a bit more trouble ... some scanners don't provide the same selectable options regarding "ignoring" certain applications.
I need to do a bit of study on this when the swirling waters subside a little.


added:
interesting vbs name !!
hehehe
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Jeff_M

  • King Gator
  • Posts: 4094
  • C3D user & customizer
IP address...
« Reply #19 on: March 05, 2005, 09:37:20 PM »
Quote from: MP
What, and take all the fun out of it?

Not my intent at all, Michael. In fact I plan on playing around with it some myself. My post was supposed to have been directed towards Andrea since it seemed like they wanted  something to work with now, it's just that Kerry and you manged to post while I was composing mine.... :?

So, carry on with your pursuit of knowledge...  :twisted:

edited in response to others' notification of Andrea's gender, which is the way I was going to post originally...my apologies to Andrea...

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
IP address...
« Reply #20 on: March 05, 2005, 10:43:01 PM »
Quote from: Jeff_M
Not my intent at all, Michael. In fact I plan on playing around with it some myself. My post was supposed to have been directed towards Andrea since it seemed like she wanted  something to work with now, it's just that Kerry and you manged to post while I was composing mine.... :?

I may be mistaken, but I thought Andrea was a >he<. :oops:

Quote from: Jeff_M
So, carry on with your pursuit of knowledge...

Indeed! You too Jeff. :lol:

Quote from: Kerry
interesting vbs name !! hehehe

Create Retrieve Update Destroy.

Moo ha ha ha. :twisted:
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

daron

  • Guest
IP address...
« Reply #21 on: March 05, 2005, 11:35:18 PM »
Ahem!!! Jeff??? Andrea is a he, not a she.



Carry-on!

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
IP address...
« Reply #22 on: March 06, 2005, 11:41:46 AM »
After trying a number of avenues it suddenly dawned on me ...

... if you add this line to your acad.pgp file:

Code: [Select]
HiddenShell,,4,*OS Command:,
This code will not flash the DOS window:

Code: [Select]
<See next post>
:D

Well off to church, catch ya later.

Edit: Removed code; superfluous given next post.
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
IP address...
« Reply #23 on: March 06, 2005, 08:20:40 PM »
Here ya go.

Written quickly. This means there are errors I failed to find | fix. Please follow prudent backup / testing methodologies. No warranty for any particular use is stated or implied. Use at your own risk.

Code: [Select]
(defun FindItemInFile ( PredicateFunction filename / handle item )

    ;;  © 2005 Michael Puckett

    (if
        (and
            (eq 'str (type filename))
            (setq handle (open filename "r"))
        )
        (vl-catch-all-apply
           '(lambda ( / stream )
                (while (setq stream (read-line handle))
                    (cond
                        (   (PredicateFunction stream)
                            (close handle)
                            (setq item stream)
                            (exit)
                        )
                    )
                )
                (close handle)
            )
        )
    )
    item
)


(defun HiddenShellInPgpFile ( / filepath filebackup handle )

    ;;  © 2005 Michael Puckett

    (or
        (FindItemInFile
            (lambda (stream)
                (wcmatch
                    (strcase (vl-string-trim " \t\n" stream))
                    "HIDDENSHELL`,`,4`,`*OS COMMAND:`,"
                )
            )
            (setq filepath (findfile "acad.pgp"))
        )
        (and
            filepath
            (setq filebackup (vl-filename-mktemp filepath))
            (vl-file-copy filepath filebackup)
            (setq handle (open filepath "a"))
            (princ "\nHiddenShell,,4,*OS Command:,\n" handle)
            (null (close handle))
            (setvar "re-init" 16)
        )
    )
)


(defun HiddenShell ( statement / cmdecho )

    ;;  © 2005 Michael Puckett

    (cond
        (
            (HiddenShellInPgpFile)
            (setq cmdecho (getvar "cmdecho"))
            (setvar "cmdecho" 0)
            (command "HiddenShell" statement)
            (setvar "cmdecho" cmdecho)
            t
        )
    )
)


(defun GetIPAddress ( / tempfile ipAddressStream ipAddress )

    ;;  © 2005 Michael Puckett

    (if
        (and

            (HiddenShell
                (strcat "ipconfig.exe > "
                    (setq tempfile
                        (vl-filename-mktemp "ipconfig.txt")
                    )
                )
            )

            (setq ipAddressStream
                (FindItemInFile
                    (lambda (stream)
                        (wcmatch
                            (strcase stream)
                            "*IP ADDRESS*"
                        )
                    )
                    tempfile
                )
            )

        )

        (setq ipAddress
            (vl-string-trim " "
                (vl-list->string
                    (cdr
                        (member 58
                            (vl-string->list ipAddressStream)
                        )
                    )
                )
            )
        )
    )

    (if tempfile (vl-file-delete tempfile)) ;; clean up our mess

    ipAddress

)

Cheers.

:D
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

ronjonp

  • Needs a day job
  • Posts: 7527
Re: IP address...
« Reply #24 on: October 25, 2006, 03:24:31 PM »
Thanks for this function MP. I can use this :)

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: IP address...
« Reply #25 on: October 25, 2006, 04:02:03 PM »
<blink> Thank you for taking the time to say so Ron!
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

Andrea

  • Water Moccasin
  • Posts: 2372
Re: IP address...
« Reply #26 on: October 26, 2006, 10:15:06 AM »
Ahem!!! Jeff??? Andrea is a he, not a she.



Carry-on!

thanks Daron. :lmao:
Keep smile...

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8691
  • AKA Daniel
Re: IP address...
« Reply #27 on: October 26, 2006, 03:24:51 PM »
Here's one

Code: [Select]
(defun ipaddress (/ item meth1 meth2 ml s wmi)
  (vl-load-com)
  (setq ml '()
WMI (vlax-create-object "WbemScripting.SWbemLocator")
meth1 (VLAX-INVOKE WMI 'ConnectServer nil nil nil nil nil nil nil nil)
meth2 (vlax-invoke meth1 'ExecQuery (strcat "Select IPAddress from Win32_NetworkAdapterConfiguration"))
S (vlax-for item meth2 (setq ml (append
  (vlax-get item 'IPAddress)
  ml
)
       )
  )
  )
  (vlax-release-object meth1)
  (vlax-release-object meth2)
  (vlax-release-object wmi)
  s
)

and
Code: [Select]
(defun ping (address / result)
  (setq result (Win32_PingStatus address))
  (if (= (cadr result) 0)
    t
    nil
  )
)
(defun Win32_PingStatus (Address / item meth1 meth2 s wmi x)
  (vl-load-com)
  (setq WMI (vlax-create-object "WbemScripting.SWbemLocator")
meth1 (VLAX-INVOKE WMI 'ConnectServer nil nil nil nil nil nil nil nil)
meth2 (vlax-invoke meth1 'ExecQuery (strcat "Select * From Win32_PingStatus where Address = '" address "'"))
S (vlax-for item meth2 (setq x (list (vlax-get item 'Address) (vlax-get item 'StatusCode) (vlax-get item 'ResponseTime))))
  )
  (vlax-release-object meth1)
  (vlax-release-object meth2)
  (vlax-release-object wmi)
  s
)

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8691
  • AKA Daniel
Re: IP address...
« Reply #28 on: October 26, 2006, 03:31:53 PM »
Now I am a Newt!  :lmao:

Andrea

  • Water Moccasin
  • Posts: 2372
Re: IP address...
« Reply #29 on: October 26, 2006, 04:12:11 PM »
nice Daniel... :roll:


this was my old one..

Code: [Select]
(command "SH" "IPCONFIG > c:\\IPCFG.txt")
(setq f1 (open "c:\\IPCFG.txt" "r"))
(setq l1 (read-line f1))
(while l1
  (setq IPyes (vl-string-search "IP." l1))
  (if IPyes
    (progn
    (setq sp (vl-string-position (ascii ":") l1))
    (setq IPA (substr l1 (+ sp 3)))
  ))
(setq l1 (read-line f1))
)
(close f1)

(alert (strcat "IP Adress is : " IPA))





;;;;;;;;;;

(defun c:ping (/ pname f1 l1 IPyes)
(setq pname (getstring "Address : "))
(if pname
  (setq bfile (open "c:\\PIGNNAME.bat" "w"))
  (write-line (strcat "PING " pname " > c:\\PIGNNAME.txt") bfile)
 (close bfile)
(command pcommand)
(startapp "c:\\PIGNNAME.bat")
))
Keep smile...