|
|
|
#1 (permalink) |
|
Messages: n/a
Hébergeur: |
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 |
|
|
|
#2 (permalink) |
|
Messages: n/a
Hébergeur: |
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 |
|
|
|
#3 (permalink) |
|
Messages: n/a
Hébergeur: |
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 > > > |
|
|
|
#4 (permalink) |
|
Messages: n/a
Hébergeur: |
"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 -- |
|
![]() |
| Outils de la discussion | |
|
|