Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
Keywords: IP address getter DEFINITIVE IP ADDRESS
I know this will involve editing the registry. I am kind of short on time and would appreciate any code you can pull off the top of your head.
for xx=0 to 9 netnum=strfixleft(xx,0,4) key ="System\CurrentControlSet\Services\Class\NetTrans\%netnum%[IpAddress]" if regexistvalue(@regmachine,key) ipaddr=RegQueryValue(@regmachine,key) ipaddr =strreplace(ipaddr,"131.87.13.","131.87.22.") RegSetValue(@regmachine,key,ipaddr) endif next
;Script by Len Sher May 11, 1998 / Modified by Marty - July 17, 1998 ;SHER_LI@exchange.phs.com ;This code fragment was written to obtain the ip address of a workstation ;from the winsock dll (wsock32.dll). Hostent = BinaryAlloc(1000) if Hostent == 0 then Message("Error", "Hostent Allocation Failed") Return endif binaryEodSet(Hostent, 16) Wsadata = BinaryAlloc(1000) if Wsadata == 0 then Message("Error", "Wsadata Allocation Failed") Return endif BinaryEodSet(Wsadata, 14) Hostname = BinaryAlloc(1000) if Hostname == 0 then Message("Error", "Hostname Allocation Failed") Return endif BinaryEodSet(Hostname, 256) length=256 ver=257 dllhandle=0 dllhandle=DllLoad(strcat(dirwindows(1), "wsock32.dll")) ret=DllCall(dllhandle, lpstr:"WSAStartup", long:ver, lpbinary:Wsadata) if ret <> "WSAStartup" then Message("Error", "Winsock dll (wsock32.dll) not responding") endif wVersion=BinaryPeek2(Wsadata, 0) ;Message("Version", wVersion) ret=DllCall(dllhandle, lpstr:"gethostname", lpbinary:Hostname, long:length) if ret == -1 then Message("Error", "Windows Sockets Error") Return endif ;Message("the computer is",BinaryPeekStr(Hostname,0,length)) hostent_addr=DllCall(dllhandle, long:"gethostbyname", lpbinary:Hostname) ;Message("hostent_addr", hostent_addr) hName=IntControl(32,hostent_addr,"LONG",0,0) ;Message("hName Pointer", hName) hostent_addr=hostent_addr + 4 hAliases=IntControl(32,hostent_addr,"LONG",0,0) ;Message("hAliases Pointer", hAliases) hostent_addr=hostent_addr + 4 hAddrType=IntControl(32,hostent_addr,"LONG",0,0) ;Message("hAddrType Pointer", hAddrType) hostent_addr=hostent_addr + 4 ;hostent_addr=hostent_addr + 12 ;ADD 12 TO POINT TO hAddrList ;Message("hostent_addr Incremented", hostent_addr) hAddrList=IntControl(32,hostent_addr,"LONG",0,0) ;Message("the hAddrList pointer is ",hAddrList) IpAddress=IntControl(32,hAddrList,"LONG",0,0) ;Message("the IpAddress pointer is ",IpAddress) ip1=IntControl(32,IpAddress,"BYTE",0,0) IpAddress=IpAddress + 1 ip2=IntControl(32,IpAddress,"BYTE",0,0) IpAddress=IpAddress + 1 ip3=IntControl(32,IpAddress,"BYTE",0,0) IpAddress=IpAddress + 1 ip4=IntControl(32,IpAddress,"BYTE",0,0) if ip1 < 0 ip1 = ip1 + 256 endif if ip2 < 0 ip2 = ip2 + 256 endif if ip3 < 0 ip3 = ip3 + 256 endif if ip4 < 0 ip4 = ip4 + 256 endif ret=DllCall(dllhandle, lpstr:"WSACleanup") if ret == -1 then Message("Error", "Windows Sockets Error") Return endif Message("the Ip Address is", strcat(ip1,".",ip2,".",ip3,".",ip4)) DllFree(dllhandle) BinaryFree(Hostent) BinaryFree(Wsadata) BinaryFree(Hostname)
Article ID: W13134
Filename: Change IP Address Automatically.txt
File Created: 1999:04:15:16:51:58
Last Updated: 1999:04:15:16:51:58