PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Forums Hébergement > Forum Hébergement serveur > ms..win.server.scripting > Client IP retrieval
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
Client IP retrieval

Réponse
 
LinkBack Outils de la discussion
Vieux 14/10/2007, 15h38   #1 (permalink)
Green-Thumb
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Client IP retrieval

I have been trying to write a script for retrieving the IP from a client.
I want to be able to send an email with the script as an attachement and my
client then would receive the email and run the script. The script would
send me an email back containing the clients IP.

Can someone me please?

B

  Réponse avec citation
Vieux 15/10/2007, 01h14   #2 (permalink)
Shenan Stanley
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Client IP retrieval

Green-Thumb wrote:
> I have been trying to write a script for retrieving the IP from a
> client.
>
> I want to be able to send an email with the script as an
> attachement and my client then would receive the email and run the
> script. The script would send me an email back containing the
> clients IP.


Well, you could do many things for this. Since your method has the client
involved anyway - why not just have them visit http://www.whatismyip.com/
and then copy/paste their IP into an email to you?

If you want the internal IP as well - that is easy enough to get - many
freeware applications you could send them links to already give them that
information and even copy to the clipboard. Example:
http://keir.net/ip2.html

I wouldn't re-invent the wheel if you don't need to. Heck - all the
machines in the domains I manage email me their internal/external IPs upon
startup. Batch script and BLAT...

--
Shenan Stanley
MS-MVP
--
How To Ask Questions The Smart Way
http://www.catb.org/~esr/faqs/smart-questions.html


  Réponse avec citation
Vieux 18/10/2007, 15h28   #3 (permalink)
Green-Thumb
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Client IP retrieval

I don't want my client to do anything, but click on an icon (Script). This
client of mine is very inept when it comes to a pc, so I want to make it as
easy as possible for them.

I would like a script that would send me an email containing the ip, both
internal and external. When my client runs the script, I receive an email
with their ip's.

I am not a script guy and I have been struggling with trying to write one.
Please .


"Shenan Stanley" wrote:

> Green-Thumb wrote:
> > I have been trying to write a script for retrieving the IP from a
> > client.
> >
> > I want to be able to send an email with the script as an
> > attachement and my client then would receive the email and run the
> > script. The script would send me an email back containing the
> > clients IP.

>
> Well, you could do many things for this. Since your method has the client
> involved anyway - why not just have them visit http://www.whatismyip.com/
> and then copy/paste their IP into an email to you?
>
> If you want the internal IP as well - that is easy enough to get - many
> freeware applications you could send them links to already give them that
> information and even copy to the clipboard. Example:
> http://keir.net/ip2.html
>
> I wouldn't re-invent the wheel if you don't need to. Heck - all the
> machines in the domains I manage email me their internal/external IPs upon
> startup. Batch script and BLAT...
>
> --
> Shenan Stanley
> MS-MVP
> --
> How To Ask Questions The Smart Way
> http://www.catb.org/~esr/faqs/smart-questions.html
>
>
>

  Réponse avec citation
Vieux 18/10/2007, 17h28   #4 (permalink)
Richard Mueller [MVP]
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Client IP retrieval


"Green-Thumb" <GreenThumb@discussions.microsoft.com> wrote in message
news:7C22ACD4-56C1-4C17-8A53-C4FDD69F1B86@microsoft.com...
>I have been trying to write a script for retrieving the IP from a client.
> I want to be able to send an email with the script as an attachement and
> my
> client then would receive the email and run the script. The script would
> send me an email back containing the clients IP.
>
> Can someone me please?


Someone else can give ideas on emailing, as that can get very complex. It
depends on what you have, such as Outlook, or other software.

Retrieving the IP address can quickly get complicated (especially on Vista
clients). Do you want IPv4 or IPv6? What if the computer has more than one
address? I've used several VBScript functions in the past, but they all give
different results on my Vista computer. The one I've used longest and is
fine for most clients (even Win9x):
==============
Option Explicit
Dim strIP

strIP = Join(GetIPAddresses())
Wscript.Echo strIP

Function GetIPAddresses()
' Based on a Michael Harris script, modified by Torgeir Bakken
'
' Returns array of IP Addresses as output
' by IPConfig or WinIPCfg...
'
' Win98/WinNT have IPConfig (Win95 doesn't)
' Win98/Win95 have WinIPCfg (WinNt doesn't)
'
' Note: The PPP Adapter (Dial Up Adapter) is
' excluded if not connected (IP address will be 0.0.0.0)
' and included if it is connected.

Dim objShell, objFSO, objEnv, strWorkFile, objFile
Dim arrData, intIndex, n, arrIPAddresses, arrParts

Set objShell = CreateObject("wscript.shell")
Set objFSO = CreateObject("scripting.filesystemobject")
Set objEnv = objShell.Environment("PROCESS")
If (objEnv("OS") = "Windows_NT") Then
strWorkFile = objEnv("TEMP") & "\" & objFSO.GetTempName
objShell.Run "%comspec% /c IPConfig >" & Chr(34) _
& strWorkFile & Chr(34), 0, True
Else
' WinIPCfg in batch mode sends output to
' filename WinIPCfg.out
strWorkFile = "WinIPCfg.out"
objShell.Run "WinIPCfg /batch", 0, True
End If
Set objShell = Nothing
Set objFile = objFSO.OpenTextFile(strWorkFile)
arrData = Split(objFile. ReadAll, vbCrLf)
objFile.Close
Set objFile = Nothing
objFSO.DeleteFile strWorkFile
Set objFSO = Nothing
arrIPAddresses = Array()
intIndex = -1
For n = 0 To UBound(arrData)
If (InStr(arrData(n), "IPv4 Address") > 0) Then
arrParts = Split(arrData(n), ":")
If (InStr(Trim(arrParts(1)), "0.0.0.0") = 0) Then
intIndex = intIndex + 1
ReDim Preserve arrIPAddresses(intIndex)
arrIPAddresses(intIndex)= Trim(CStr(arrParts(1)))
End If
End If
Next
GetIPAddresses = arrIPAddresses
End Function
==============
If the client has more than one address, they are shown space delimited.
Another method that requires WMI (will run on most clients with W2k or
above), but outputs IPv6 on Vista:
================
Option Explicit
Dim objNetwork, strComputer
Dim objWMIService, colComputers, objComputer

Set objNetwork = CreateObject("Wscript.Network")
strComputer = objNetwork.ComputerName

Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colComputers = objWMIService.ExecQuery _
("SELECT * FROM Win32_PingStatus WHERE Address = '" & strComputer & "'")

For Each objComputer In colComputers
Wscript.Echo objComputer.ProtocolAddress
Next
==============
And another requiring WMI that gives different results:
============
Option Explicit
Dim objNetwork, strComputer
Dim objWMIService, colItems, objItem

Set objNetwork = CreateObject("Wscript.Network")
strComputer = objNetwork.ComputerName

Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery _
("SELECT IPAddress FROM Win32_NetworkAdapterConfiguration WHERE
IPEnabled='True'")

For Each objItem In colItems
Wscript.Echo Join(objItem.IPAddress, ",")
Next
===========

--
Richard Mueller
Microsoft MVP Scripting and ADSI
Hilltop Lab - http://www.rlmueller.net
--


  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 11h25.


Édité par : vBulletin® version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,15207 seconds with 12 queries