Good Morning
I cleaned up the script as the board suggested. Here is what I have been able to get this script to. Thanks again for all your help but will this work. I am thinking of combining WMI and Kix to achive the desired result. Take a look at the final script which should set the default gateways of my machines based on the subnet Mask.

code:
 
Break On
$hklm='HKEY_LOCAL_MACHINE'
Select
Case InStr(@PRODUCTTYPE,'Windows NT')
$OS_SHORT='WinNT'
Case InStr(@PRODUCTTYPE,'Windows 2000')
$OS_SHORT='Win2K'
Case InStr(@PRODUCTTYPE,'Windows XP')
$OS_SHORT='WinXP'
Case 1
Return
EndSelect
$tempfile = "%temp%\ipconfig.tmp"

Shell '%comspec% /c ipconfig /all | find /i "Subnet Mask" >"$tempfile" 2>nul'

If Open(1,$tempfile) = 0
$line = ReadLine(1)
$SBNM = Ltrim(SubStr($line,InStr($line,":")+1))
?"Subnet Mask=" $SBNM
EndIf

$IpPart1 = Ltrim(SubStr(@IPADDRESS0, 1, 4))
$IpPart2 = Ltrim(SubStr(@IPADDRESS0, 5, 4))
$IpPart3 = Ltrim(SubStr(@IPADDRESS0, 9, 4))
$IpPart4 = Ltrim(SubStr(@IPADDRESS0, 13, 3))
$IPAddressComplete = $IpPart1 + $IpPart2 + $IpPart3 + $IpPart4
$IPSUBN=$IpPart1 + $IpPart2 + $IpPart3
$Octet = Val(SubStr(@ipaddress0,13,3))

If $SBNM
Select
Case $SBNM='255.255.255.0'
$NDG=$IPSUBN + '252'
$NDG1=$IPSUBN + '251'
Case $SBNM='255.255.255.128'
Select
Case $Octet<=126
$NDG=$IPSUBN + '124'
$NDG1=$IPSUBN + '123'
Case $Octet<=254
$NDG=$IPSUBN + '251'
$NDG1=$IPSUBN + '252'
EndSelect
Case $SBNM='255.255.255.192'
Select
Case $Octet<=62
$NDG=$IPSUBN + '60'
$NDG1=$IPSUBN + '59'
Case $Octet<=126
$NDG=$IPSUBN + '124'
$NDG1=$IPSUBN + '123'
Case $Octet<=190
$NDG=$IPSUBN + '188'
$NDG1=$IPSUBN + '187'
Case $Octet<=254
$NDG=$IPSUBN + '251'
$NDG1=$IPSUBN + '252'
EndSelect
Case $SBNM='255.255.255.224'
; nothing
EndSelectEndif

?" Your default gateway is address is "$NDG
?" Your default gateway is address is "$NDG1
? " Your Os is "@PRODUCTTYPE
Select

Case $OS_SHORT='WinNT'

Case $OS_SHORT='Win2K'
;netsh interface ip Set adrress "@ipaddress0" "$SBNM" "$NDG"
Case $OS_SHORT='WinXP'
;netsh interface ip Set adrress "@ipaddress0" "$SBNM $NDG"

$strComputer = "."
$ObjWMIservice = GetObject("winmgmts:\\"+$strComputer+"\root\cimv2")
$colNetAdapters = $objWMIService.ExecQuery("Select * from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE")
For Each $objNetAdapter in $colNetAdapters
$errGateways = $objNetAdapter.SetGateways($NDG, 1)
Next
Exit1




The WMI part I am too sure about but it does seem to make sense a little bit ?