Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
Some of the variables might not be set, but it uses netsh to do the configurations.
; Setup the Log file CurrPath = FilePath(IntControl(1004, 0, 0, 0, 0)) CMSLog = StrCat(CurrPath, "CMSServerBuild.log") sIPAddr="" sSubNetMask="" sIPGateway="" sDNS1="" sDNS2="" sWINS1="" sWINS2="" ;============================================================================== ; UDFWriteLog ;============================================================================== ; This function will write out the Log file and a message with the date prepended. #DefineFunction UDFWriteLog(LogFile, LogText) CurrDate = TimeDate ( ) handle = FileOpen(LogFile, "APPEND") Logme = Strcat(CurrDate, @TAB, @TAB, LogText) FileWrite(handle, Logme) FileClose(handle) Return #EndFunction ;UDFWriteLog ;============================================================================== ; GETSTDOUT ;============================================================================== #DefineFunction GetSTDOUT(cmd) ;Turn on debugging during development CurrPath = FilePath(IntControl(1004, 0, 0, 0, 0)) sTrcFile = Strcat(CurrPath,"~CMSServerBuild.trc") DebugTrace(@ON,sTrcFile) objShell = ObjectOpen("WScript.Shell") objWshScriptExec = objShell.Exec(cmd) objStdOut = objWshScriptExec.StdOut line="" While ! objStdOut.AtEndOfStream strLine = objStdOut.ReadLine if line == "" ;check if first line line = strCat(strLine,@CR) else line = strCat(line,strLine,@CR) endif Endwhile ObjectClose(objStdOut) ObjectClose(objWshScriptExec) ObjectClose(objShell) Return line #EndFunction ;GETSTDOUT ; Set the IP configuration on the Teamed NIC. Do this before we rename the LAC to Team. PassThis = StrCat('cmd /c netsh interface ip set address name="Local Area Connection" source=static addr=', sIPAddr , ' mask=', sSubNetMask, ' gateway=', sIPGateway , ' gwmetric=1') NetshRslt = GetSTDOUT(PassThis) If udf_ChkNetShErr(NetshRslt) == "ERROR" UDFWriteLog(CMSLog, StrCat("ERROR changing IP address, error was ", NetshRslt)) Goto CMSError Else UDFWriteLog(CMSLog, StrCat("Changed the IP Address to", sIPAddr)) Endif PassThis = StrCat('cmd /c netsh interface ip set dns name="Local Area Connection" source=static addr=', sDNS1) ; PassThis = 'cmd /c netsh interface ip set dns name="Local Area Connection" source=static addr=159.140.160.73' NetshRslt = GetSTDOUT(PassThis) If udf_ChkNetShErr(NetshRslt) == "ERROR" UDFWriteLog(CMSLog, StrCat("ERROR setting DNS, error was ", NetshRslt)) Goto CMSError Else UDFWriteLog(CMSLog, StrCat("Changed the DNS1 Address to", sDNS1)) Endif PassThis = StrCat('cmd /c netsh interface ip add dns name="Local Area Connection" addr=', sDNS2, ' index=2') ; PassThis = 'cmd /c netsh interface ip add dns name="Local Area Connection" addr=159.140.160.72 index=2' NetshRslt = GetSTDOUT(PassThis) If udf_ChkNetShErr(NetshRslt) == "ERROR" UDFWriteLog(CMSLog, StrCat("ERROR adding DNS address, error was ", NetshRslt)) Goto CMSError Else UDFWriteLog(CMSLog, StrCat("Changed the DNS2 Address to", sDNS2)) Endif PassThis = StrCat('cmd /c netsh interface ip set wins name="Local Area Connection" source=static addr=', sWINS1) ; PassThis = 'cmd /c netsh interface ip set wins name="Local Area Connection" source=static addr=159.140.160.73' NetshRslt = GetSTDOUT(PassThis) If udf_ChkNetShErr(NetshRslt) == "ERROR" UDFWriteLog(CMSLog, StrCat("ERROR setting WINS, error was ", NetshRslt)) Goto CMSError Else UDFWriteLog(CMSLog, StrCat("Changed the WINS1 Address to", sWINS1)) Endif PassThis = StrCat('cmd /c netsh interface ip add wins name="Local Area Connection" addr=' ,sWINS2') ; PassThis = 'cmd /c netsh interface ip add wins name="Local Area Connection" addr=159.140.160.72' NetshRslt = GetSTDOUT(PassThis) If udf_ChkNetShErr(NetshRslt) == "ERROR" UDFWriteLog(CMSLog, StrCat("ERROR adding WINS, error was ", NetshRslt)) Goto CMSError Else UDFWriteLog(CMSLog, StrCat("Changed the WINS1 Address to", sWINS2)) Endif ;============================================================================== ; CMSERROR ;============================================================================== :CMSError UDFWriteLog(CMSLog, "Error CMS Server Build exited abnormally") IntControl (1000, 2, 0, 0, 0) ; Setup the Return value to be 2, errored out. Exit
Article ID: W16216
File Created: 2004:03:30:15:43:18
Last Updated: 2004:03:30:15:43:18