OK, but I hate VarsInStrings.
This is not my code, I just shortened the lines.
Code:
BREAK ON
$Wins1 = "1.1.1.1"
$Wins2 = "1.1.1.1"
$Dns1 = "1.1.1.1"
$Dns2 = "1.1.1.1"
$Dns3 = "1.1.1.1"
$list = "C:\winsList.txt"
$log = "C:\winsLog.txt"
$ = open(2, $log, 5)
$ = open(1, $list)
$curComp = trim(readline(1))
while @error = 0 and $curComp <> ""
? $curComp
$_Exit = 0
$_SubnetMask = ""
$Found = 0
$_NicIndex = 0
gosub "DetectOS"
$HKLMSMWNTCV = 'HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion'
$HKLSSCCSS = 'HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services'
$HKLMSCCSC = 'HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control'
if $OS <> "Invalid OS" and $OS <> "Unreachable"
Do
$_NicKey = EnumKey("\\$curComp\$HKLMSMWNTCV\NetworkCards\", $_NicIndex)
If $_NicKey <> ""
$_NicClass = ReadValue("\\$curComp\$HKLMSMWNTCV\NetworkCards\$_NicKey", "ServiceName")
If @Error = 0
$_DHCP = ReadValue("\\$curComp\$HKLSSCCSS\$_NicClass\Parameters\Tcpip", "EnableDHCP")
If $_DHCP = 1
$_SubnetMask = ReadValue("\\$curComp\$HKLSSCCSS\$_NicClass\Parameters\Tcpip", "DhcpSubnetMask")
Else
$_SubnetMask = ReadValue("\\$curComp\$HKLSSCCSS\$_NicClass\Parameters\Tcpip", "SubnetMask")
EndIf
If @Error = 0
If $_SubnetMask <> "0.0.0.0|"
$Found = 1
$_Exit = 1
EndIf
EndIf
If $Found = 1
If $OsType = "WinNT"
$Nul = WriteValue("\\$curComp\$HKLSSCCSS\NetBT\Adapters\$_NicClass", "NameServer", $Wins1, "REG_SZ")
$Nul = WriteValue("\\$curComp\$HKLSSCCSS\NetBT\Adapters\$_NicClass", "NameServerBackup", $Wins2, "REG_SZ")
$Nul = WriteValue("\\$curComp\$HKLSSCCSS\Tcpip\Parameters", "NameServer", $DNS1
+ " " + $Dns2 + " " + $Dns3, "REG_SZ")
EndIf
If ($OsType = "Win2k") Or ($OsType = "WinXP")
$Nul = WriteValue("\\$curComp\$HKLSSCCSS\NetBT\Parameters\Interfaces\Tcpip_$_NicClass", "NameServerList", $Wins1
+ "|" + $Wins2 + "|", "REG_MULTI_SZ")
$Nul = WriteValue("\\$curComp\$HKLSSCCSS\Tcpip\Parameters\Interfaces\$_NicClass", "NameServer", $DNS1
+ "," + $Dns2 + "," + $Dns3, "REG_SZ")
EndIf
$ = writeline(2, $curComp + ",Wins Updated" + @crlf)
EndIf
EndIf
Else
$_Exit = 1
EndIf
If $Found = 0
$_NicIndex = $_NicIndex + 1
EndIf
Until $_Exit = 1
Else
$ = writeline(2, $curComp + "," + $OS + @crlf)
EndIf
$curComp = trim(readline(1))
loop
$ = close(1)
$ = close(2)
RETURN
:DetectOS
;This will determine the exact Operating System of a machine.
$ProductType = ReadValue("\\$curComp\$HKLMSCCSC\ProductOptions","ProductType")
$dos = ReadValue("\\$curComp\$HKLMSMWNTCV", "CurrentVersion")
SELECT
CASE $ProductType = "" and $dos = ""
$OS = "Unreachable"
CASE $dos = "5.1" AND $ProductType = "WinNT"
$OS = "Windows XP"
$OSType = "WinXP"
CASE $ProductType = "WinNT" AND $dos="5.0"
$OS = "Windows 2000 Professional"
$OSType = "WIN2K"
CASE $ProductType = "WinNT"
$OS = "Windows NT Workstation"
$OSType = "WINNT"
CASE 1
$OS = "Invalid OS"
ENDSELECT
Return