David Regev
asked on
Convert Case To if Statement on vbscript
Hi
how can i convert this script from case to If
Option Explicit
On Error Resume Next
Select Case DefaultGateway
Case "10.2.254.1"
'Do something
Case "10.3.254.1"
'Do something
Case "10.4.254.1"
'Do something
Case "10.5.254.1"
'Do something
Case "10.6.254.1"
'Do something
End Select
Function DefaultGateway
DefaultGateway = Empty
Dim oDG, oDGs, WMI
Set WMI = GetObject("winmgmts:\\.\ro ot\cimv2")
Set oDGs = WMI.ExecQuery _
("Select * from Win32_NetworkAdapterConfig uration where IPEnabled=TRUE")
For Each oDG In oDGs
If Not IsNull(oDG.DefaultIPGatewa y) Then
If Not oDG.defaultIPGateway(0) = "0.0.0.0" Then
DefaultGateway = oDG.DefaultIPGateway(0)
Exit For
End If
End If
Next
End Function
how can i convert this script from case to If
Option Explicit
On Error Resume Next
Select Case DefaultGateway
Case "10.2.254.1"
'Do something
Case "10.3.254.1"
'Do something
Case "10.4.254.1"
'Do something
Case "10.5.254.1"
'Do something
Case "10.6.254.1"
'Do something
End Select
Function DefaultGateway
DefaultGateway = Empty
Dim oDG, oDGs, WMI
Set WMI = GetObject("winmgmts:\\.\ro
Set oDGs = WMI.ExecQuery _
("Select * from Win32_NetworkAdapterConfig
For Each oDG In oDGs
If Not IsNull(oDG.DefaultIPGatewa
If Not oDG.defaultIPGateway(0) = "0.0.0.0" Then
DefaultGateway = oDG.DefaultIPGateway(0)
Exit For
End If
End If
Next
End Function
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.