/build/static/layout/Breadcrumb_cap_w.png

Getting IP Address

Hi,

We are doing this because we want to develope a package that will not execute anything if they are either connected via our VPN or dailup. During VPN and dialup connections they will always on on a certain IP rang. This is to prevent forcing large pacakges down a small pipe. I was looking at grabing this varible from the registry but not sure where to get it or if there is an easier why to grab it.

Any help would be great.

0 Comments   [ + ] Show comments

Answers (2)

Posted by: bheers 19 years ago
Second Degree Blue Belt
0
get the service name from

HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkCards\1\ServiceName

put that in a Variable

and substitute that variable in

"HKLM\SYSTEM\CurrentControlSet\Services\TCPIP\Parameters\Interfaces\<Variable>"
in that you have "DhcpIPAddress" that is the IPADDRESS of the system.

"I HAVE NOT TESTED THE BELOW CODE, MAY NEED SOME MODIFICATIONS"
_______________________________________________________________

' Script to retrieve the current IP Address on the first network card.
'
' (c) 2002 A.J. Elsinga
' anne.jan@network-direct.com
'
' version 1.0


' ************************************************************
' *** Start of functions and procedures ***
' ************************************************************

Function GetIPAddress
' This function retrieves the IP Address from the registry
' It gets it from the CurrentControlSet, so even when using DHCP
' it returns the correct IP Address

' Declare variables

Dim key
Dim cTempIPAddress
Dim cIPAddress
dim cIPAddressKey


Set oSh = CreateObject("WScript.Shell")

cInterfacesKey="HKLM\SYSTEM\CurrentControlSet\Services\TCPIP\Parameters\Interfaces\"
cNICSearch="HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkCards\1\ServiceName"


' First check which network card to use
cNicServiceName=oSh.RegRead(cNICSearch)

' Now read the IP Address from that card
cIPAddressKey=cInterfaceskey + cNicServiceName+"\IPAddress"
cTempIPAddress=oSh.RegRead (cIPAddresskey)

' Split the items in the var tempIPAddress to the octets in array IPAddress
cIPAddress=split (cTempIPAddress(0),".",4)

' the IP addresss is now readable from ipaddress
' for example, to read the first octet, use: FirstOctet=IPAddress(0)

GetIPAddress=cIPAddress
End Function

Function GetIPOctet (nOctet)
' This function retrieves a given octet out of the IP Address
Dim IPAddress

IPAddress=GetIPAddress
GetIPOctet=IPAddress(nOctet-1)
End Function

_________________________________________________________________________
Posted by: sean_c_roberts 19 years ago
Senior Purple Belt
0
Alternatively:

Paste what's in between the dotted lines into notepad and save as GetIP.wse (the load into the WiseScript Editor...

---------------------------------------------------
Document Type: WSE
item: Global
Version=8.13
Title=Get IP addresses
Flags=00000100
Languages=65 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Japanese Font Name=MS Gothic
Japanese Font Size=9
Progress Bar DLL=%_WISE_%\Progress\WIZ%_EXE_OS_TYPE_%.DLL
Start Gradient=0 0 255
End Gradient=0 0 0
Windows Flags=00000100000000010010110000001000
Message Font=MS Sans Serif
Font Size=8
Pages Modified=00100000001000000000000000000000
Extra Pages=00000000000000000000000000010000
Disk Label=Default
Disk Filename=SETUP
Patch Flags=0000000000000001
Patch Threshold=85
Patch Memory=4000
FTP Cluster Size=20
Dialogs Version=7
Crystal Format=10111100101100000010001001001001
Step View=&Properties
Variable Name1=_SYS_
Variable Default1=C:\WINDOWS\SYSTEM
Variable Flags1=00001000
Variable Name2=_WIN_
Variable Default2=C:\WINDOWS
Variable Flags2=00001000
Variable Name3=_WISE_
Variable Default3=C:\PROGRAMME\WISE INSTALLMASTER 8.1
Variable Flags3=00001000
Variable Name4=_INIT_WINDOW_
Variable Default4=HIDE
Variable Flags4=00001000
end
item: Remark
Text=File: get_ip.wse
end
item: Remark
Text=Purpose: Sample script demonstrating how to retrieve the IP address of every machine visible on the local network
end
item: Remark
Text=Requires: Wise InstallBuilder/InstallMaster 7.x or higher
end
item: Remark
Text=Author: Ralf Buschmann
end
item: Remark
Text=Date: 9/21/2001
end
item: Remark
Text=Contact: ralf@backmagic.de
end
item: Remark
Text=
end
item: Remark
end
item: Remark
Text=Load 32bit Winsock DLL
end
item: Call DLL Function
Pathname=%SYS32%\KERNEL32.DLL
Function Name=LoadLibraryA
Argument List=41%SYS32%\WSOCK32.DLL
Return Variable=3HWSOCK32DLL
Flags=00100000
end
item: If/While Statement
Variable=HWSOCK32DLL
Value=0
end
item: Display Message
Title=Get IP Addresses
Text=TCP/IP not properly installed!
Flags=00110000
end
item: Else Statement
end
item: Remark
Text=Initialize Winsock
end
item: Call DLL Function
Pathname=%SYS32%\WSOCK32.DLL
Function Name=WSAStartup
Argument List=110x0101
Argument List=q0VERSION
Argument List=±0VERSIONHIGH
Argument List=¹0@ÿDESCRIPTION
Argument List=¹0¡ SYSTEMSTATE
Argument List=±0MAXSOCKETS
Argument List=±0MAXUDPDG
Argument List=´0VENDORINFO
Return Variable=2RETURN
Flags=00100000
end
item: If/While Statement
Variable=RETURN
Value=0
Flags=00000001
end
item: Display Message
Title=Get IP Addresses
Text=Error initializing Winsock layer!
Flags=00110000
end
item: Else Statement
end
item: Get Temporary Filename
Variable=MACHINES
end
item: Set Variable
Variable=MACHINES
Value=%TEMP%\%MACHINES%
Flags=00010100
end
item: Get Environment Variable
Variable=COMSPEC
Environment=COMSPEC
end
item: If/While Statement
Variable=COMSPEC
Flags=00000001
end
item: Set Variable
Variable=COMSPEC
Value=%COMSPEC%
Flags=00010100
end
item: Remark
Text=Execute a "net view" command and send it's output to the temporary file.
end
item: Remark
Text=We use the ShellExecuteEx API to run the command hidden (no ugly DOS window)...
end
item: Custom Script Item
Filename=Display Progress Message.wse
Variable Name1=_CENTER_
Variable Value1=AB
Variable Name2=_WIDTH_
Variable Value2=350
Variable Name3=_MSG_TITLE_
Variable Value3=Getting IP addresses...
Variable Name4=HELPFILE
Variable Value4=C:\PROGRAMME\WISE INSTALLMASTER 8.1\WISE.HLP
Variable Name5=_OPTION_
Variable Value5=B
Variable Name6=_HEIGHT_
Variable Value6=100
Variable Name7=_Y_POS_
Variable Name8=_MSG_TEXT_
Variable Value8=Searching the network, please wait...
Variable Name9=_X_POS_
end
item: Call DLL Function
Pathname=%SYS32%\SHELL32.DLL
Function Name=ShellExecuteEx
Argument List=s160
Argument List=³10x440
Argument List=³2
Argument List=´1open
Argument List=´0COMSPEC
Argument List=´1/c net view>%MACHINES%
Argument List=´0WIN
Argument List=²10
Argument List=³0HINSTAPP
Argument List=¹14
Argument List=³0HPROCESS
Return Variable=3RETURN
Flags=00100000
end
item: If/While Statement
Variable=RETURN
Value=0
Flags=00000001
end
item: Remark
Text=... wait for it to finish ...
end
item: Call DLL Function
Pathname=%SYS32%\KERNEL32.DLL
Function Name=WaitForSingleObject
Argument List=30HPROCESS
Argument List=310xFFFFFFFF
Return Variable=3
Flags=00100000
end
item: Remark
Text=... and don't forget to close the process handle.
end
item: Call DLL Function
Pathname=%SYS32%\KERNEL32.DLL
Function Name=CloseHandle
Argument List=30HPROCESS
Return Variable=3
Flags=00100000
end
item: Remark
Text=Parse the file
end
item: Set Variable
Variable=MACHINES_IP
end
item: Read/Update Text File
Variable=LINE
Pathname=%MACHINES%
end
item: If/While Statement
Variable=LINE
Value=\\
Flags=00000010
end
item: Remark
Text=This is a line containing a host name
end
item: Parse String
Source=%LINE%
Pattern=\\
Variable2=MACHINE
Flags=00000001
end
item: Set Variable
Variable=IPADDRESS
Value=unknown
end
item: Remark
Text=Resolve host name to IP address
end
item: Call DLL Function
Pathname=%SYS32%\WSOCK32.DLL
Function Name=gethostbyname
Argument List=40MACHINE
Return Variable=3HOSTENTPTR
Flags=00100000
end
item: If/While Statement
Variable=HOSTENTPTR
Value=0
Flags=00000001
end
item: Call DLL Function
Pathname=%SYS32%\KERNEL32.DLL
Function Name=RtlMoveMemory
Argument List=s0NAME_PTR
Argument List=³0ALIASES_PTR
Argument List=°0ADDRESS_TYPE
Argument List=°0ADDRESS_LENGTH
Argument List=³0IP_PTR_PTR
Argument List=30HOSTENTPTR
Argument List=3116
Return Variable=3
Flags=00100000
end
item: Remark
Text=Store the host's IP address in variable IPADDRESS:
end
item: Call DLL Function
Pathname=%SYS32%\KERNEL32.DLL
Function Name=RtlMoveMemory
Argument List=80IP_PTR
Argument List=30IP_PTR_PTR
Argument List=314
Return Variable=3
Flags=00100000
end
item: Call DLL Function
Pathname=%SYS32%\KERNEL32.DLL
Function Name=RtlMoveMemory
Argument List=80BINARY_IP
Argument List=30IP_PTR
Argument List=314
Return Variable=3
Flags=00100000
end
item: Call DLL Function
Pathname=%SYS32%\WSOCK32.DLL
Function Name=inet_ntoa
Argument List=30BINARY_IP
Return Variable=3IPADDRESS_PTR
Flags=00100000
end
item: Call DLL Function
Pathname=%SYS32%\KERNEL32.DLL
Function Name=lstrcpyA
Argument List=40IPADDRESS
Argument List=30IPADDRESS_PTR
Return Variable=3
Flags=00100000
end
item: End Block
end
item: Remark
Text=Build a CR/LF separated of machine names and associated IP address
end
item: Set Variable
Variable=MACHINES_IP
Value=%MACHINE% %IPADDRESS%%CRLF%
Flags=00000001
end
item: End Block
end
item: End Block
end
item: End Block
end
item: Custom Script Item
Filename=Display Progress Message.wse
Variable Name1=_CENTER_
Variable Name2=_WIDTH_
Variable Name3=_MSG_TITLE_
Variable Value3=
Variable Name4=HELPFILE
Variable Value4=C:\PROGRAMME\WISE INSTALLMASTER 8.1\WISE.HLP
Variable Name5=_OPTION_
Variable Value5=A
Variable Name6=_MSG_TEXT_
Variable Name7=_Y_POS_
Variable Name8=_HEIGHT_
Variable Name9=_X_POS_
end
item: End Block
end
item: Remark
Text=Clean up Winsock
end
item: Call DLL Function
Pathname=%SYS32%\WSOCK32.DLL
Function Name=WSACleanup
Return Variable=2RETURN
Flags=00100000
end
item: End Block
end
item: Remark
Text=Unload Winsock DLL
end
item: Call DLL Function
Pathname=%SYS32%\KERNEL32.DLL
Function Name=FreeLibrary
Argument List=30HWSOCK32DLL
Return Variable=3
Flags=00100000
end
item: End Block
end
item: Custom Dialog Set
Name=IP addresses
item: Dialog
Title=IP addresses
Width=150
Height=150
Font Name=Helv
Font Size=8
item: Push Button
Rectangle=55 114 90 129
Enabled Color=00000000000000001111111111111111
Create Flags=01010000000000010000000000000001
Text=OK
end
item: Static
Rectangle=5 5 140 23
Enabled Color=00000000000000001111111111111111
Create Flags=01010000000000000000000000000000
Text=These are the machines visible on the local network and their associated IP addresses
end
item: Editbox
Rectangle=5 30 140 110
Variable=MACHINES_IP
Help Context=2147483649
Enabled Color=00000000000000001111111111111111
Create Flags=01010000101100010000100011000100
Text=%MACHINES_IP%
end
end
end
------------------------------------------------------------------
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ