Convert to DHCP from Static IP Addressing
Keywords: DHCP Static IP
Question:
I have 50+/- systems that are still using static IP addressing. I use WinBatch to make some system
changes on login and would like to convert these folks to DHCP at that time - I realize that a reboot
would be necessary. Does anyone have code for the registry changes necessary for Win 95/98/NT?
Answer:
Been there - done that. This program requires that the user already has a static IP address. It will probe
the registry keys to find the proper folder and make the necessary changes. It is also geared to only run
one time on each PC as it was written to run from a Novell login script. Hope this helps:
; DHCP Enable for 199 segment
; Written by Todd Thorson, XXXXX CIS
; Date Written 3/4/1999
Errormode(@OFF)
If RegQueryValue(@REGMACHINE,"software\XXXXX\DistServices[DHCPEnable]") == "yes" then
EXIT
WinType=WinMetrics(-4)
If WinType != 5 then EXIT
While WinExist("Program Manager") == @FALSE
Delay(1)
EndWhile
Delay(5)
LastMod="3/4/1999"
LANID=Environment("ln")
FileSvr=Environment("fs")
AppSvr=Environment("asvr")
FullName=Environment("FN")
TD=TimeDate()
Owner=Environment("owner")
Psvr=Environment("psvr")
RAM=((WinResources(11))/1024)/1000
Decimals(1)
free=(DiskFree("c")/1024)/1000
If free > 1000 then
freeb=StrCat((free/1000),"GB")
Else
freeb=StrCat(free,"MB")
EndIf
WHITE="255,255,255"
RED="255,0,0"
PURPLE="255,0,255"
CYAN="0,255,255"
DKBLUE="0,0,128"
BLUE="0,0,255"
LTGRAY="192,192,192"
MAGENTA="225,0,255"
GRAY="128,128,128"
GREEN="0,255,0"
YELLOW="255,255,0"
FAMILY=16
FONT="Arial"
DKGRAY="64,64,64"
BLACK="0,0,0"
WBTVER=VersionDll()
WASH=5
Winver=RegQueryValue(@REGMACHINE,"Software\Microsoft\Windows\CurrentVersion[Version]")
VerNum=RegQueryValue(@REGMACHINE,"Software\Microsoft\Windows\CurrentVersion[VersionNumber]")
VerSub=RegQueryValue(@REGMACHINE,"Software\Microsoft\Windows\CurrentVersion[SubVersionNumber]")
If VerSub == 0 then VerSub=" "
IP = 0
For X = 0 to 9 by 1
If IP == 0 then
IP=RegQueryValue(@REGMACHINE,"System\CurrentControlSet\Services\Class\NetTrans\000%X%[IpAddress]")
If IP == "0.0.0.0" then IP = 0
If IP != 0
IPFolder = "000%x%"
goto GotIP
EndIf
Next
For Y = 10 to 25 by 1
If IP == 0 then
IP=RegQueryValue(@REGMACHINE,"System\CurrentControlSet\Services\Class\NetTrans\00%Y%[IpAddress]")
If IP == "0.0.0.0" then IP = 0
If IP != 0
IPFolder = "00%Y%"
goto GotIP
EndIf
Next
If IP == 0 then IP="Not Found"
:GotIp
If IP == "Not Found" then EXIT
RegSetValue(@REGMACHINE,"System\CurrentControlSet\Services\Class\NetTrans\%IPFolder%[IpAddress]","0.0.0.0")
RegSetValue(@REGMACHINE,"System\CurrentControlSet\Services\Class\NetTrans\%IPFolder%[IpMask]","0.0.0.0")
RegDelValue(@REGMACHINE,"System\CurrentControlSet\Services\Class\NetTrans\%IPFolder%[DefaultGateway]")
RegDelValue(@REGMACHINE,"System\CurrentControlSet\Services\Class\NetTrans\%IPFolder%[NameServer1]")
RegDelValue(@REGMACHINE,"System\CurrentControlSet\Services\Class\NetTrans\%IPFolder%[NameServer2]")
RegSetValue(@REGMACHINE,"System\CurrentControlSet\Services\VXD\MSTCP[EnableDNS]","0")
BoxesUp("0,0,1000,1000",@NORMAL)
BoxColor(1,"0,0,127",WASH)
BoxCaption(1,"XXXXX Distributed Services")
BoxDrawRect(1,"0,0,1000,1000",1)
BoxTextFont(1,"%font%",150,80,0|0)
BoxTextColor(1,"255,255,0")
BoxNew(4,"100,10,900,160",1)
BoxColor(4,LTGRAY,0)
BoxDrawRect(4,"",1)
BoxTextFont(4,"%font%",350,70,0)
BoxTextColor(4,MAGENTA)
BoxPen(4,WHITE,20)
boxdrawline(4,"0,0,1000,0")
boxdrawline(4,"0,0,0,1000")
BoxPen(4,GRAY,20)
boxdrawline(4,"1000,1000,1000,0")
boxdrawline(4,"0,1000,1000,1000")
BoxPen(4,WHITE,10)
boxdrawline(4,"960,840,960,150")
boxdrawline(4,"40,840,960,840")
BoxPen(4,GRAY,10)
boxdrawline(4,"40,150,960,150")
boxdrawline(4,"40,150,40,840")
BoxDrawText(4,"70,200,950,700","DHCP Client Install Utility",1,5)
BoxTextFont(4,"%font%",140,30,0)
BoxDrawText(4,"500,650,950,800","Program Created %lastmod%",1,5)
BoxTextFont(1,"%font%",30,30,0|0)
TextLine1="Your machine now has DHCP enabled. The server will now assign your PC's address as you
login, rather than a technician assigning a permanent number for each PC. "
TextLine2="This allows easier administration of the network, and reduces the chance of duplicate
numbers.%@CRLF%You should not notice any changes in the operation of your PC."
TextLine=StrCat(TextLine1,TextLine2)
TextLine3="Configuration is complete. Thank you for your patience.%@CRLF%If you have any
questions, call the Help Desk in RSMT at 3636."
TextLine4="Press 'OK' to reboot your PC and start with the new configuration."
BoxTextColor(1,WHITE)
BoxDrawText(1,"50,250,950,450",TextLine,@FALSE,1|16)
BoxTextFont(1,"%font%",45,50,0|0)
BoxTextColor(1,YELLOW)
BoxDrawText(1,"100,500,900,650",TextLine3,@FALSE,1)
BoxTextFont(1,"%font%",30,40,0|0)
BoxTextColor(1,WHITE)
BoxDrawText(1,"100,750,900,850",TextLine4,@FALSE,1|16)
RegSetValue(@REGMACHINE,"software\XXXXX\DistServices[DHCPEnable]","yes")
RegSetValue(@REGMACHINE,"software\XXXXX\DistServices[DHCPDate]",TD)
BoxButtonDraw(1,1, "&OK", "400,875,600,925")
BoxButtonWait()
IntControl(67,0,0,0,0)
Article ID: W14291
Filename: Convert to DHCP from Static IP Addressing.txt