Re: Case Select, Printers comparing IP addresses by KevinC
KevinC
Sat Jan 20 13:01:02 CST 2007
This will split the IP address into 4 parts and then run a case select for
the 3rd Octet:
'##StartScript##'
strIPAddress= "10.25.61.100"
strIPAddress = split(strIPAddress, ".")
strOctet1 = strIPAddress(0)
strOctet2 = strIPAddress(1)
strOctet3 = strIPAddress(2)
strOctet4 = strIPAddress(3)
Select Case StrOctet3
Case "61"
Wscript.echo("Third Octet = 61")
Case "85"
Wscript.echo("Third Octet = 85")
Case "55"
Wscript.echo("Third Octet = 55")
End Select
'##ENDScript##'
--
Kevin Callanan
MSCA 2003, A+, Network+
www.weblabtechs.com
Please let us know if this response was helpful...
"Mike" wrote:
> Hi Ray,
>
> That part of the Select Case will find the third octet. It's this
> variable that I need to compare for my printer choices.
>
> i.e
>
>
> 142.166.85.10
>
> aOctets=85 (From your script)
>
> I want to take this number and compare to a list so I can run different
> VBS for printers in a office.
>
> I'm thinking something like this....
>
> Dim oNetwork, sPrintPath, sLocate
> Set oNetwork = CreateObject("WScript.Network")
> ' Begin callout A
> sLocate =_
> InputBox("Where would you like to print? Type the corresponding
> number? 1 = RD Lab
> 2 = Office Color
> 3 = B&W Office")
> ' End callout A
> Select Case sLocate
> Case "1"
> sPrintPath = "\\ddc\rd_Lab_RM173"
> Case "2"
> sPrintPath = "\\ddc\color_Office"
> Case "3"
> sPrintPath = "\\ddc\BW_Office"
> Case Else
> MsgBox("That is not a valid choice. The script will exit.")
> :WScript.Quit
> End Select
> oNetwork.AddWindowsPrinterConnection sPrintPath
> oNetwork.SetDefaultPrinter sPrintPath
> Set WshNetwork = CreateObject("WScript.Network")
> WshNetwork.AddWindowsPrinterConnection "\\ddc\rd_Lab_RM173", "R&D Lab
> RM173"
> WshNetwork.AddWindowsPrinterConnection "\\ddc\color_Office", "Color
> Laser Office"
> WshNetwork.AddWindowsPrinterConnection "\\ddc\Lab_Office", "B&W Office"
>
>
> What do you think?
>
>