getting IP address 
Author Message
 getting IP address

I want to write a script to that when run by a user on their machine
will return the ip address allocated to the ppp dial up adaptor .

Is this possible?

Charlie Markwick



Sun, 10 Aug 2003 00:32:50 GMT  
 getting IP address
'-----------------------------------------------------------------------

'-----------------------------------------------------------------------
'Idealy you will set this to run in task scheduler once every so often.
'It will check the current ip address with an old ip address and if the
'ip has changed then it will email you the new ip address.
'Program was wrote on win98 machine.  To use email you must have
'office installed on the computer you are gonna run this from.
'-----------------------------------------------------------------------
'This program creates 2 extra files in the scripts directory.
'Winipcfg.OUT & OldIP.txt
'-----------------------------------------------------------------------
'If you want to try this out without reconnecting then after you run the
'program change OldIP.txt to a different ip address.
'-----------------------------------------------------------------------

Dim CurrentIP, fso, IPFile, SPath, FileIP, OldIPFile, OldIP, EmailAddress

'-----------------------------------------------------------------------
'IMPORTANT  ============================================================
'=======================================================================

'If there is more than one email address to send to then seperate them

'-----------------------------------------------------------------------

Set fso = CreateObject("Scripting.FileSystemObject")
Set WshShell = WScript.CreateObject("WScript.Shell")

SPath = fso.GetAbsolutePathName("C:")
IPFile = SPath & "\winipcfg.out"
OldIPFile = SPath & "\oldip.txt"

'---------------------------------------------------------------------------

Main()
Sub Main()

 If CheckForFile(IsThere) = 1 Then
  GetOldIP()
  RunBat()
  CheckForNewIP()
  If CurrentIP = OldIP Then
       'Dont do anything because the ip address is the same :)
  Else
   WCurrentIP()    'write the current ip to log file
   SendMail()        'send the updated ip to the email address
  End If
 Else
  CreateBat()
  CheckForNewIP()
  WCurrentIP()
 End If

set fso = nothing
set WshShell = nothing
End Sub

'---------------------------------------------------------------------------

Function CheckForFile(IsThere)
 If fso.fileExists(IPFile) Then
  CheckForFile = 1
 Else
  CreateBat()
  Return = WshShell.Run("C:\GetIp.bat", 1, True)
  CheckForFile = 0
 End If
End Function

'---------------------------------------------------------------------------

Function CreateBat()
Dim BatFile
 Set BatFile = fso.OpenTextFile("C:\GetIp.bat",2,True)

      "winipcfg /batch" &vbcrlf &_

  BatFile.Close
 Set BatFile = Nothing
End Function
'---------------------------------------------------------------------------
Function GetOldIP()

 Dim File, CLine
 If fso.FileExists(OldIPFile) Then

 Else
  Set File = fso.OpenTextFile(OldIPFile,2,True)
  File.write "No IP"
  File.Close
 End If

 Set File = fso.OpenTextFile(OldIPFile,1)
  CLine = File.ReadLine
  OldIP = CLine

 File.Close
 Set File = Nothing
End Function

'---------------------------------------------------------------------------

Function CheckForNewIP()
 Dim File, CLine
 On Error Resume Next
 Set File = fso.OpenTextFile(IPFile,1)
  For i = 1 To 6 Step 1
   CLine = File.ReadLine
  Next
 CurrentIP = Right(CLine,12)
 File.Close
 Set File = nothing

End Function

'---------------------------------------------------------------------------

Function WCurrentIP()
 Dim File
 Set File = fso.OpenTextFile(OldIPFile,2,True)
  File.Write CurrentIP
 File.Close
 Set File = nothing
End Function

'---------------------------------------------------------------------------

Function RunBat()
Return = WshShell.Run("C:\GetIp.bat", 1, True)
End Function

Function SendMail()
set out=WScript.CreateObject("Outlook.Application")
set Message=out.CreateItem(0)
     Message.Recipients.Add(EmailAddress)
     Message.Subject = "IP CHANGE"
     Message.Body = "IP Changed From " & OldIP & " to " & CurrentIP & "."
     Message.Attachments.Add(IPFile)
     Message.Send
Set out = Nothing
Set Message = Nothing
End Function


Quote:
> I want to write a script to that when run by a user on their machine
> will return the ip address allocated to the ppp dial up adaptor .

> Is this possible?

> Charlie Markwick



Sun, 10 Aug 2003 09:28:18 GMT  
 getting IP address
There must be a shorter way to do this, no?

/Al


Quote:
> '-----------------------------------------------------------------------

> '-----------------------------------------------------------------------
> 'Idealy you will set this to run in task scheduler once every so often.
> 'It will check the current ip address with an old ip address and if the
> 'ip has changed then it will email you the new ip address.
> 'Program was wrote on win98 machine.  To use email you must have
> 'office installed on the computer you are gonna run this from.
> '-----------------------------------------------------------------------
> 'This program creates 2 extra files in the scripts directory.
> 'Winipcfg.OUT & OldIP.txt
> '-----------------------------------------------------------------------
> 'If you want to try this out without reconnecting then after you run the
> 'program change OldIP.txt to a different ip address.
> '-----------------------------------------------------------------------

> Dim CurrentIP, fso, IPFile, SPath, FileIP, OldIPFile, OldIP, EmailAddress

> '-----------------------------------------------------------------------
> 'IMPORTANT  ============================================================
> '=======================================================================

> 'If there is more than one email address to send to then seperate them

> '-----------------------------------------------------------------------

> Set fso = CreateObject("Scripting.FileSystemObject")
> Set WshShell = WScript.CreateObject("WScript.Shell")

> SPath = fso.GetAbsolutePathName("C:")
> IPFile = SPath & "\winipcfg.out"
> OldIPFile = SPath & "\oldip.txt"

'---------------------------------------------------------------------------

- Show quoted text -

Quote:

> Main()
> Sub Main()

>  If CheckForFile(IsThere) = 1 Then
>   GetOldIP()
>   RunBat()
>   CheckForNewIP()
>   If CurrentIP = OldIP Then
>        'Dont do anything because the ip address is the same :)
>   Else
>    WCurrentIP()    'write the current ip to log file
>    SendMail()        'send the updated ip to the email address
>   End If
>  Else
>   CreateBat()
>   CheckForNewIP()
>   WCurrentIP()
>  End If

> set fso = nothing
> set WshShell = nothing
> End Sub

'---------------------------------------------------------------------------
Quote:

> Function CheckForFile(IsThere)
>  If fso.fileExists(IPFile) Then
>   CheckForFile = 1
>  Else
>   CreateBat()
>   Return = WshShell.Run("C:\GetIp.bat", 1, True)
>   CheckForFile = 0
>  End If
> End Function

'---------------------------------------------------------------------------
Quote:

> Function CreateBat()
> Dim BatFile
>  Set BatFile = fso.OpenTextFile("C:\GetIp.bat",2,True)

>       "winipcfg /batch" &vbcrlf &_

>   BatFile.Close
>  Set BatFile = Nothing
> End Function

'---------------------------------------------------------------------------

- Show quoted text -

Quote:
> Function GetOldIP()

>  Dim File, CLine
>  If fso.FileExists(OldIPFile) Then

>  Else
>   Set File = fso.OpenTextFile(OldIPFile,2,True)
>   File.write "No IP"
>   File.Close
>  End If

>  Set File = fso.OpenTextFile(OldIPFile,1)
>   CLine = File.ReadLine
>   OldIP = CLine

>  File.Close
>  Set File = Nothing
> End Function

'---------------------------------------------------------------------------
Quote:

> Function CheckForNewIP()
>  Dim File, CLine
>  On Error Resume Next
>  Set File = fso.OpenTextFile(IPFile,1)
>   For i = 1 To 6 Step 1
>    CLine = File.ReadLine
>   Next
>  CurrentIP = Right(CLine,12)
>  File.Close
>  Set File = nothing

> End Function

'---------------------------------------------------------------------------
Quote:

> Function WCurrentIP()
>  Dim File
>  Set File = fso.OpenTextFile(OldIPFile,2,True)
>   File.Write CurrentIP
>  File.Close
>  Set File = nothing
> End Function

'---------------------------------------------------------------------------

- Show quoted text -

Quote:

> Function RunBat()
> Return = WshShell.Run("C:\GetIp.bat", 1, True)
> End Function

> Function SendMail()
> set out=WScript.CreateObject("Outlook.Application")
> set Message=out.CreateItem(0)
>      Message.Recipients.Add(EmailAddress)
>      Message.Subject = "IP CHANGE"
>      Message.Body = "IP Changed From " & OldIP & " to " & CurrentIP & "."
>      Message.Attachments.Add(IPFile)
>      Message.Send
> Set out = Nothing
> Set Message = Nothing
> End Function



> > I want to write a script to that when run by a user on their machine
> > will return the ip address allocated to the ppp dial up adaptor .

> > Is this possible?

> > Charlie Markwick



Sun, 10 Aug 2003 13:47:04 GMT  
 getting IP address
Stick this in your <body>

<% Resonse.Write(Request.ServerVariables) %>("REMOTE_ADDR"))

Paul Tozer


Quote:
> There must be a shorter way to do this, no?

> /Al



> > '-----------------------------------------------------------------------

> > '-----------------------------------------------------------------------
> > 'Idealy you will set this to run in task scheduler once every so often.
> > 'It will check the current ip address with an old ip address and if the
> > 'ip has changed then it will email you the new ip address.
> > 'Program was wrote on win98 machine.  To use email you must have
> > 'office installed on the computer you are gonna run this from.
> > '-----------------------------------------------------------------------
> > 'This program creates 2 extra files in the scripts directory.
> > 'Winipcfg.OUT & OldIP.txt
> > '-----------------------------------------------------------------------
> > 'If you want to try this out without reconnecting then after you run the
> > 'program change OldIP.txt to a different ip address.
> > '-----------------------------------------------------------------------

> > Dim CurrentIP, fso, IPFile, SPath, FileIP, OldIPFile, OldIP,
EmailAddress

> > '-----------------------------------------------------------------------
> > 'IMPORTANT  ============================================================
> > '=======================================================================

> > 'If there is more than one email address to send to then seperate them

> > '-----------------------------------------------------------------------

> > Set fso = CreateObject("Scripting.FileSystemObject")
> > Set WshShell = WScript.CreateObject("WScript.Shell")

> > SPath = fso.GetAbsolutePathName("C:")
> > IPFile = SPath & "\winipcfg.out"
> > OldIPFile = SPath & "\oldip.txt"

'---------------------------------------------------------------------------

- Show quoted text -

Quote:

> > Main()
> > Sub Main()

> >  If CheckForFile(IsThere) = 1 Then
> >   GetOldIP()
> >   RunBat()
> >   CheckForNewIP()
> >   If CurrentIP = OldIP Then
> >        'Dont do anything because the ip address is the same :)
> >   Else
> >    WCurrentIP()    'write the current ip to log file
> >    SendMail()        'send the updated ip to the email address
> >   End If
> >  Else
> >   CreateBat()
> >   CheckForNewIP()
> >   WCurrentIP()
> >  End If

> > set fso = nothing
> > set WshShell = nothing
> > End Sub

'---------------------------------------------------------------------------
Quote:

> > Function CheckForFile(IsThere)
> >  If fso.fileExists(IPFile) Then
> >   CheckForFile = 1
> >  Else
> >   CreateBat()
> >   Return = WshShell.Run("C:\GetIp.bat", 1, True)
> >   CheckForFile = 0
> >  End If
> > End Function

'---------------------------------------------------------------------------
Quote:

> > Function CreateBat()
> > Dim BatFile
> >  Set BatFile = fso.OpenTextFile("C:\GetIp.bat",2,True)

> >       "winipcfg /batch" &vbcrlf &_

> >   BatFile.Close
> >  Set BatFile = Nothing
> > End Function

'---------------------------------------------------------------------------

- Show quoted text -

Quote:
> > Function GetOldIP()

> >  Dim File, CLine
> >  If fso.FileExists(OldIPFile) Then

> >  Else
> >   Set File = fso.OpenTextFile(OldIPFile,2,True)
> >   File.write "No IP"
> >   File.Close
> >  End If

> >  Set File = fso.OpenTextFile(OldIPFile,1)
> >   CLine = File.ReadLine
> >   OldIP = CLine

> >  File.Close
> >  Set File = Nothing
> > End Function

'---------------------------------------------------------------------------

- Show quoted text -

Quote:

> > Function CheckForNewIP()
> >  Dim File, CLine
> >  On Error Resume Next
> >  Set File = fso.OpenTextFile(IPFile,1)
> >   For i = 1 To 6 Step 1
> >    CLine = File.ReadLine
> >   Next
> >  CurrentIP = Right(CLine,12)
> >  File.Close
> >  Set File = nothing

> > End Function

'---------------------------------------------------------------------------
Quote:

> > Function WCurrentIP()
> >  Dim File
> >  Set File = fso.OpenTextFile(OldIPFile,2,True)
> >   File.Write CurrentIP
> >  File.Close
> >  Set File = nothing
> > End Function

'---------------------------------------------------------------------------

- Show quoted text -

Quote:

> > Function RunBat()
> > Return = WshShell.Run("C:\GetIp.bat", 1, True)
> > End Function

> > Function SendMail()
> > set out=WScript.CreateObject("Outlook.Application")
> > set Message=out.CreateItem(0)
> >      Message.Recipients.Add(EmailAddress)
> >      Message.Subject = "IP CHANGE"
> >      Message.Body = "IP Changed From " & OldIP & " to " & CurrentIP &
"."
> >      Message.Attachments.Add(IPFile)
> >      Message.Send
> > Set out = Nothing
> > Set Message = Nothing
> > End Function



> > > I want to write a script to that when run by a user on their machine
> > > will return the ip address allocated to the ppp dial up adaptor .

> > > Is this possible?

> > > Charlie Markwick



Mon, 25 Aug 2003 00:34:30 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. OCI.DLL (Oracle)

2. Reportsmith and Empty lines in labels

3. THINK Pascal--Documentation

4. Queue holding stack elements

5. Question about OLE Automation and Microsoft Project

6. Turbo Pascal web info

7. how to put picture in the delphi database?

8. apology

9. DBListbox incremental search

10. Connecting to Oracle Server

11. Getting IP Address from VB5

12. Getting IP address of current machine with VB5

 

 
Powered by phpBB® Forum Software