title: Change default gateway using vbscript by altering last octet of IP
body: <p>User is asked to manually input the IP i.e 192.168.0.2
  The gateway will then change to 192.168.0.254
  The InStrRev() and Left() functions should work just can't quite get it to run.   </p>
  
  <pre><code> Set objWMIService = GetObject( "winmgmts://./root/CIMV2" )
      strQuery = "SELECT * FROM Win32_NetworkAdapterConfiguration WHERE MACAddress &gt; ''"
      Set colNetAdapters = objWMIService.ExecQuery _ 
          (strQuery)  
  
      strIPAddress = Array(InputBox("IP address"))
      strSubnetMask = Array("255.255.255.0") 
      strGateway = Left(strIPAddress, InStrRev(strIPAddress, ".")) &amp; "254"
      strGatewayMetric = Array(1) 
  
      For Each objNetAdapter in colNetAdapters 
          errEnable = objNetAdapter.EnableStatic(strIPAddress, strSubnetMask) 
          errGateways = objNetAdapter.SetGateways(strGateway, strGatewaymetric) 
          If errEnable = 0 Then 
              WScript.Echo "The IP address has been changed." 
          Else 
              WScript.Echo "The IP address could not be changed." 
          End If 
  
      next
  </code></pre>