illmaticone
OSNN Junior Addict
- Joined
- 30 Jan 2006
- Messages
- 45
hello,
im trying to create a login script that will install the proper printers based on your ip
currently we use two ip ranges
192.168.100.0
and
192.168.0.0
right now im trying to get this to work with 1 network, then i will introduce the second network once i get this working
currently the scrip works but only if it compares to 1 ip, cant figure out how to have it check,, idealy i would like it to do this..
compare ip to 192.168.100.* or 192.168.0.* or what ever the case maybe.
any help or suggestions will be greatly appreciated
im trying to create a login script that will install the proper printers based on your ip
currently we use two ip ranges
192.168.100.0
and
192.168.0.0
right now im trying to get this to work with 1 network, then i will introduce the second network once i get this working
currently the scrip works but only if it compares to 1 ip, cant figure out how to have it check,, idealy i would like it to do this..
compare ip to 192.168.100.* or 192.168.0.* or what ever the case maybe.
Code:
Dim strComputer
Dim objWMIService
Dim colItemSet
Dim colItem
Dim i
Dim wNetwork
Dim printerPath
Dim printerPath2
Dim printerPath3
Dim printerPath4
strComputer = "."
On Error Resume Next
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
On Error GoTo 0
If Not (objWMIService Is Nothing) Then
Set colItemSet = objWMIService.execQuery _
("Select * from Win32_NetworkAdapterConfiguration Where IPEnabled=TRUE")
For Each colItem In colItemSet ' There should only be one active one
If Not IsNull(colItem.IPAddress) Then
For i = LBound(colItem.IPAddress) To UBound(colItem.IPAddress)
If colItem.IPAddress(i) <> "0.0.0.0" Then 'any other connections to a PC such as bluetooth create a blank IP
If colItem.IPAddress(i) = "192.168.100.104" Then
Set wNetwork = WScript.CreateObject("WScript.Network")
printerPath = "\\sam1\KM-200"
wNetwork.AddWindowsPrinterConnection printerPath
printerPath2 = "\\sam1\KM-250"
wNetwork.AddWindowsPrinterConnection printerPath2
printerPath2 = "\\sam1\KM-350"
wNetwork.AddWindowsPrinterConnection printerPath2
printerPath2 = "\\sam1\KM-420"
wNetwork.AddWindowsPrinterConnection printerPath2
WScript.Quit
End If
End If
Next
End If
Next
End If
any help or suggestions will be greatly appreciated
Last edited by a moderator: