Hi All,

I interested in a small project. I have a vbscripts to find the IP
address of the local machine. I would like the 3rd octet of the IP to
be compared to a list using Case Select to allows users to choose
printers avaliable in their own building.

IP is detected

3rd Octet is stored in a variable

That varible becomes one of the Case Select choices

The Case Select then presents a list of available printers.

Any Ideas?

Re: Case Select, Printers comparing IP addresses by Ray

Ray
Wed Aug 09 15:26:07 CDT 2006

So you already have the IP then? In that case, let's say the IP is stored
in a variable named sIP.

aOctets = Split(sIP, ".")

Select Case something
Case Condition1
''code
Case Condition2
''code
Case aOctets(2)
''third octet match
Case Else
''code
End Select

Ray at work

<mike.white@gnb.ca> wrote in message
news:1155144461.669336.78200@p79g2000cwp.googlegroups.com...
> Hi All,
>
> I interested in a small project. I have a vbscripts to find the IP
> address of the local machine. I would like the 3rd octet of the IP to
> be compared to a list using Case Select to allows users to choose
> printers avaliable in their own building.
>
> IP is detected
>
> 3rd Octet is stored in a variable
>
> That varible becomes one of the Case Select choices
>
> The Case Select then presents a list of available printers.
>
> Any Ideas?
>



Re: Case Select, Printers comparing IP addresses by Mike

Mike
Fri Aug 11 09:13:51 CDT 2006

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?


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?
>
>