IP Address of Notes Client PC -- not Web

I got the following code from this forum and it works when I run it from either a button on a form or from a button in an email. But when I send the email to anyone else, it doesn’t work. The error messages differ from one machine to another.

Cannot open file

Cannot open automation object

File not found

All I need to do is get the IP address of the Notes Client PC. This is not a web application.

Here’s the code that works for me. Any suggestions would be appreciated:

Function Get_IP

’ create a scripting object, find out the environ, then

'either run winipcfg Or ipconfig

’ put result in a text file, read it, delete it

On Error Goto eh

Dim ws As Variant

Dim fso As Variant

Dim tmpFile As String

Dim thisLine As String

Dim ip As String

Set ws = CreateObject(“WScript.Shell”)

Set fso = CreateObject(“Scripting.FileSystemObject”)

Dim folderStr As String

TmpFile = “C:\Temp\ip.txt”

If ws.Environment(“SYSTEM”)(“OS”) = “” Then

’ attempt to establish whether win9x or nt based o/s

ws.run "winipcfg /batch " & TmpFile, 0, True

Else

ws.run "%comspec% /c ipconfig > " & TmpFile, 0, True

End If

Dim fileNum As Integer

fileNum = Freefile()

Open TmpFile For Input As fileNum

Do While Not Eof(fileNum)

Line Input #fileNum, ThisLine

If Instr(ThisLine, “Address”) <> 0 Then

IP = Mid(ThisLine, Instr(ThisLine, “:”) + 2)

Exit Do

End If

Loop

Msgbox (IP)

Close fileNum

Kill TmpFile

'WinXP (NT? 2K?) leaves a carriage return at the end of line

If IP <> “” Then

If Asc(Right(IP, 1)) = 13 Then IP = Left(IP, Len(IP) - 1)

End If

Get_IP = IP

Exit Function

eh:

’ if there was a problem here it’s best to bail out completely

End

End Function

Sub Click(Source As Button)

Get_IP

End Sub

Subject: IP Address of Notes Client PC – not Web

Are you sure this isn’t an ECL issue? As you know, Notes is very protective of objects in the file system of the PC it is running on, and the fact that you are getting different error messages depending on the user makes me think “permissions”. (You don’t get the error because your ID has ECL rights on your PC.)

  1. I assume the other users aren’t getting ECL dialogue boxes? This may be because this kind of script doesn’t trigger them.

  2. Did the forum entry where you got the script say anything about ECLs?

  3. Will your script create a C:\Temp directory if there isn’t already one? (You don’t seem to test for that.)

If ECLs aren’t the problem, you can always comment out different lines in the script (or use “Exit Function”) to determine exactly where the script is failing. If you do that and repost, someone should be able to help you.

HTHs