Results 1 to 7 of 7
  1. #1
    2 Star Lounger
    Join Date
    Jan 2001
    Location
    Edinburgh, Midlothian, Scotland
    Posts
    144
    Thanks
    0
    Thanked 0 Times in 0 Posts

    VBS - IP Address

    Does anyone know whether it is possible to return the IP address of a PC within VB Script - I want to create a script that my users can run that returns their IP address in a message box.

    TIA,

  2. #2
    Plutonium Lounger
    Join Date
    Oct 2001
    Location
    Lexington, Kentucky, USA
    Posts
    12,107
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: VBS - IP Address

    Well this isn't a scripting answer, but couldn't you do it with a simple batch file on the user machines, using either NBTSTAT or IPCONFIG or whatever, using the pause command to keep the window open until they press a key?

  3. #3
    Plutonium Lounger Leif's Avatar
    Join Date
    Dec 2000
    Location
    U.K.
    Posts
    14,010
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: VBS - IP Address

    Not VB script, but would this javascript code from the JavaScript Source do?

  4. #4
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: VBS - IP Address

    The last time I researched this, a couple of years ago, the answer was that you needed to use either Server Side Includes (SHTML) or ASP, if you are hosting on a Microsoft web server (IIS). An ordinary web page (HTM or HTML) does not seem to have access to the HTTP headers sent by the browser.

    I wish I still had the code handy, because there was a neat trick. Oh wait, maybe I posted it. Searching... searching... got it! See <post#=129006>post 129006</post#>. (Incidentally, that prank was extremely well received.)

  5. #5
    2 Star Lounger
    Join Date
    Jan 2001
    Location
    Edinburgh, Midlothian, Scotland
    Posts
    144
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: VBS - IP Address

    Many thanks for all the pointers - much appreciated. Javascript looks like the way forward for my needs.

    Thanks again,

  6. #6
    2 Star Lounger
    Join Date
    Jan 2001
    Location
    Edinburgh, Midlothian, Scotland
    Posts
    144
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: VBS - IP Address

    By complete coincidence, I came across a VBS script that does the job and am posting for future reference.

    You can find (and download) a script at http://www.billsway.com/vbspage/ - look for the "Get IP Address" script. Note that all scripts on this site are copyrighted by Bill James and the usual disclaimers apply.

    Cheers,

  7. #7
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: VBS - IP Address

    For anyone interested in this script, what it appears to do is run the command line ipconfig program (or in Windows 9x systems, winipcfg), capture its output to a file, and then extract the user's IP address from there. In looking at my original post, I obviously was assuming that the script would have to run inside a browser. Running directly off the PC provides many more options. <img src=/S/smile.gif border=0 alt=smile width=15 height=15>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •