WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

How To
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

DNS Suffix


Question:

Is there a way of querrying Win2000/xp machines to see if their dns suffix has been set and to what if it has?

If the dns suffix has not been set is there a way to set the dns suffix on Win2000/xp through a script?

Answer:

Maybe using the WMI Win32_NetworkAdapterConfiguration class...

http://techsupt.winbatch.com/webcgi/webbatch.exe?techsupt/nftechsupt.web+WinBatch/WMI+WMI~ExecQuery.txt

Or...

You can do that via registry calls. Here is an working example.

Usage:

DNSSuffixChanger.exe <param1> <param2>
<param1> = path to DNS suffix Search list. If param1 is -rollback the DNS Search list will be populated with the contents of the rollback file (param2)

<param2> = path to the roll back. This doubles as a marker file also. Before a change is made, the dns search list gets saved to this file.

;DNSSUFFIXCHANGER.WBT
;arcater 9/11/2003 - V1.0 - Created
;arcater 9/16/2003 - v1.01 - if os == nt the include suffix

;param1 = "-Rollback"
;param1 = "SuffixList.txt"
;param2 = "rollbackfile.txt"


;[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters]
;"MaxDomainsSearchListSize"=dword:0000000c

;regsetdword
;x=regexistvalue(@regmachine,"SYSTEM\CurrentControlSet\Services\Tcpip\Parameters[MaxDomainsSearchListSize]")
;message("",x)
;exit

if param0 == 0
   mess=fileget("DNSSUffixChanger.txt","")
	message("Error! No parameters Supplied",Mess)
	exit
endif

rollback = "x"
if isdefined(param1) then rollback = StriCmp(param1,"-rollback")
if rollback == 0 then goto rollback


gosub checkforparam2
gosub Checkifdone
gosub getos
gosub errorchecking
gosub setkey
gosub getnewsuffix
gosub saveoldsuffix
gosub setsuffix
exit

:rollback
gosub checkforparam2
gosub Checkforrollbackfile
gosub getrollbacksuffix
gosub setkey
gosub setsuffix
;gosub deleterollbackfile
exit



:getos
Plat=WinVersion(5)
delim = "bad"
if Plat=="2-4-0" then delim = " ";space for nt
if Plat=="2-5-0" then delim = ",";, for w2k
if Plat=="2-5-1" then delim = ",";, for Xp
return

:errorchecking
if delim == "bad"
   message("Error! Unsupported OS","The new DNS Search Suffix was not updated to your PC because you are runing an unsupported platform. Please call the responce center at 1-800-315-9088")
   exit
endif

if !isdefined(param1)
   Message("Error! Missing Suffix List","Param1 must be supplied as the path to the Suffix list")
	exit
endif

if !fileexist(param1)
   Message("Error! Could not find Suffix list",param1)
	exit
endif
return

:checkforparam2
if !isdefined(param2)
   Message("Error! Missing Path to rollback file","Param2 must be supplied as the path to Roll back file.")
	exit
endif
return

:checkifdone
if fileexist(param2) then exit
return

:setkey
key = "SYSTEM\CurrentControlSet\Services\Tcpip\Parameters[SearchList]"
return

:getnewsuffix
newsuffix = FileGet(param1,"")
newsuffix = strreplace(newsuffix,@crlf,delim)
return

:saveoldsuffix
OldSuffix = regqueryvalue(@regmachine,key)
fileput(param2,oldsuffix)
return

:setsuffix
regsetvalue(@regmachine,key,newsuffix)
return

:getrollbacksuffix
newsuffix = FileGet(param2,"")
return

:deleterollbackfile
filedelete(param2)
return

:Checkforrollbackfile
if !fileexist(param2)
   Message("Error! Missing Rollback file",Param2)
	exit
endif
return

Article ID:   W15971
File Created: 2014:07:18:09:51:38
Last Updated: 2014:07:18:09:51:38