×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Map network printers based on workstation IP addresses

Map network printers based on workstation IP addresses

Map network printers based on workstation IP addresses

(OP)
thread329-1642011: Map printers based on workstation IP addresses.
Does anyone know what the resolution to this thread was for the network printing portion? I'm in the same spot as this guy was... I am looking for a VBScript that automatically adds printers based on the third octet in the IP address to determine which set of printers get mapped to the user's machine. I am very new to scripting, so please make you explanation as basic as possible. If you can highlight the area where I would need to input my specifics, that would be great. NB: As a bonus, I would love to be able to remove existing network printers prior to mapping the new ones.
Thanks in advance.

RE: Map network printers based on workstation IP addresses

Since that thread involved a lot of code that was modified here and there, it would be easier for you to start by posting the code you are trying now, and explain what is (or is not) working.

RE: Map network printers based on workstation IP addresses

(OP)
Honestly, I don't know anything about scripting so I was hoping to just use some of the code that was in the previous post. Here's what I have...

Set objShell = CreateObject("Wscript.Shell")
set objExec = objShell.Exec("%comspec% /c ipconfig.exe")
set objNetwork = WScript.CreateObject("WScript.Network")

'loop through the stream looking for key phrase "IP Address"
do while NOT (objExec.Stdout.AtEndOfStream)

strLine = objExec.Stdout.ReadLine
if(inStr(strLine, "IP Address")) then
'Parse strLine to obtain IP.
strIP = trim(right(strLine, len(strLine) - inStrRev(strLine, ":")))
exit do
end if
loop
arrTokens = split(strIP, ".")
select case strIP arrTokens(2)
'2nd Floor
case "10.231.147"
objNetwork.AddWindowsPrinterConnection "\\nesvr-prt01\add_2nd_flr_printers.bat"

end select

I get the following error:

Line: 18
Char: 4
Error: Syntax error
Code: 800A03EA
Source: Microsoft VBScript compilation error

RE: Map network printers based on workstation IP addresses

Assuming you want it based on the first three octets, the code below cleans up the retrieval of the IP address anyway:

CODE

Set objShell = CreateObject("Wscript.Shell")
Set objExec = objShell.Exec("%comspec% /c ipconfig.exe")
Set objNetwork = WScript.CreateObject("WScript.Network")

'loop through the stream looking for key phrase "IP Address"
Do While NOT (objExec.Stdout.AtEndOfStream)

	strLine = objExec.Stdout.ReadLine
	If (InStr(strLine, "IP Address")) Then
		'Parse strLine to obtain IP.
		strIP = Trim(Right(strLine, Len(strLine) - InStrRev(strLine, ":")))
		Exit Do
	End If
Loop

arrTokens = Split(strIP, ".")
strIPBase  = arrTokens(0) & "." & arrTokens(1) & "." & arrTokens(2)
Select Case strIPBase 
	'2nd Floor
	Case "10.231.147"
		objNetwork.AddWindowsPrinterConnection "\\nesvr-prt01\add_2nd_flr_printers.bat"

End Select 

Note that this uses the output of "ipconfig.exe" to retrieve the local IP address, which is not a good method. For one, the text I hightlighted would work in XP, but not in Win7 for example (the text is IPv4 Address in Win7). You might be better off using a WMI query to get the IP address, like the code in the link below:
http://community.spiceworks.com/topic/256186-ip-ad...

RE: Map network printers based on workstation IP addresses

(OP)
Sounds good.. I made a few tweaks. My goal is to have this be a logon script where it pulls the IP from the workstation and then determines, based on the third octet of the IP, which printer script to run. Does that make sense? I appreciate your help.

CODE -->

dim NIC1, Nic, sIP

Set NIC1 = GetObject("winmgmts:").InstancesOf("Win32_NetworkAdapterConfiguration")
if Nic.IPEnabled then
sIP = Nic.IPAddress(i)
Set WshNetwork = WScript.CreateObject("WScript.Network")

iFirstDot = InStr(0, sIP,".")
iSecondDot = InStr(iFirstDot+1,sIP,".")
iThirdDot = InStr(iSecondDot+1,sIP,".")
sThirdOctet = Mid(sIP, iSecondDot+1, Len(sIP)-iThirdDot)

'Map printer based on octet
Select Case sThirdOctet
   case "146"
	MapPrinter "\\nesvr-prt01\!Print drivers\Omaha Printers\add_2nd_flr_printers.bat"
   case "147"
	MapPrinter "\\nesvr-prt01\!Print drivers\Omaha Printers\add_2nd_flr_printers.bat"

end Select 

I get the following error:
Line: 20
Char: 11
Error: Expected 'End'
Code: 800A03F7
Source: Microsoft VBScript compilation error

RE: Map network printers based on workstation IP addresses

1) This code is quite different from what you posted originally. And if you executed the code you just posted, you would have gotten errors long before "Line 20 Expected End", so I dont really know what code you're working with now.
2) You did not include all the relevant code to get the IP address from the link I gave above. I moved the relevant code to a function called "GetIP" below to help clean things up.
3) I do not know what "MapPrinter" is, so I will assume it's a subroutine that you did not post, and that it works properly.

CODE

sIP = GetIP()
If sIP <> "" Then
	
   iFirstDot = InStr(1, sIP,".")
   iSecondDot = InStr(iFirstDot+1,sIP,".")
   iThirdDot = InStr(iSecondDot+1,sIP,".")
   sThirdOctet = Mid(sIP, iSecondDot+1, Len(sIP)-iThirdDot)

   'Map printer based on octet
   Select Case iThirdDot
      case "146"
         MapPrinter "\\nesvr-prt01\!Print drivers\Omaha Printers\add_2nd_flr_printers.bat"
      case "147"
         MapPrinter "\\nesvr-prt01\!Print drivers\Omaha Printers\add_2nd_flr_printers.bat"
   end Select 
end If


Function GetIP()
   dim NIC1, Nic, StrIP, CompName
   Set NIC1 = GetObject("winmgmts:").InstancesOf("Win32_NetworkAdapterConfiguration")
   For Each Nic in NIC1
      if Nic.IPEnabled then
         GetIP = Nic.IPAddress(i)
      end if
   next
End Function 

RE: Map network printers based on workstation IP addresses

The Select should have read:
 Select Case sThirdOctet 

RE: Map network printers based on workstation IP addresses

(OP)
Ok so I updated a few things... I do not get any error codes but when I run the vbscript the printer scripts from the print server are not running so I'm assuming something isn't right.. do you have any idea what that might be?

CODE -->

set objNetwork = WScript.CreateObject("WScript.Network")
sIP = GetIP()
If sIP <> "" Then
	
   iFirstDot = InStr(1, sIP,".")
   iSecondDot = InStr(iFirstDot+1,sIP,".")
   iThirdDot = InStr(iSecondDot+1,sIP,".")
   sThirdOctet = Mid(sIP, iSecondDot+1, Len(sIP)-iThirdDot)

   'Map printer based on octet
   Select Case iThirdOctet
      case "146"
         objNetwork.AddWindowsPrinterConnection "\\nesvr-prt01\!Print drivers\Omaha Printers\add_2nd_flr_printers.bat"
      case "147"
         objNetwork.AddWindowsPrinterConnection "\\nesvr-prt01\!Print drivers\Omaha Printers\add_2nd_flr_printers.bat"
   end Select 
end If


Function GetIP()
   dim NIC1, Nic, StrIP, CompName
   Set NIC1 = GetObject("winmgmts:").InstancesOf("Win32_NetworkAdapterConfiguration")
   For Each Nic in NIC1
      if Nic.IPEnabled then
         GetIP = Nic.IPAddress(i)
      end if
   next
End Function 

RE: Map network printers based on workstation IP addresses

Another way to identify the third octet would be to just split the IPAddress based on the periods. I think this is a little easier to follow for that portion. Arrays start at zero, so the first octet is element zero, the second octet is element 1, the third is element 2 and the final octet is element 3.

CODE --> VBScript

IPAddress = "192.168.100.18"
IPArray = Split(IPAddress,".")
ThirdOctet = IPArray(2)
WScript.Echo "Third Octet is:" & ThirdOctet 

I hope that helps.

Regards,

Mark

No trees were harmed in posting this message, however a significant number of electrons were terribly inconvenienced.

Check out my scripting solutions at http://www.thespidersparlor.com/vbscript

Work SMARTER not HARDER.

RE: Map network printers based on workstation IP addresses

(OP)
Okay Mark, that seems easier than what I had... how would you replace that in the current code so that it is functional? I tried the following but get an error on line 6. Sorry I'm so new at scripting, literally picked it up this last week.

CODE --> VBScript

set objNetwork = WScript.CreateObject("WScript.Network")
sIP = GetIP()
If sIP <> "" Then
	
   IPArray = Split(IPAddress,".")
   ThirdOctet = IPArray(2)

   'Map printer based on octet
   Select Case ThirdOctet
      case "146"
         objNetwork.AddWindowsPrinterConnection "\\nesvr-prt01\!Print drivers\Omaha Printers\add_2nd_flr_printers.bat"
      case "147"
         objNetwork.AddWindowsPrinterConnection "\\nesvr-prt01\!Print drivers\Omaha Printers\add_2nd_flr_printers.bat"
   end Select 
end If


Function GetIP()
   dim NIC1, Nic, StrIP, CompName
   Set NIC1 = GetObject("winmgmts:").InstancesOf("Win32_NetworkAdapterConfiguration")
   For Each Nic in NIC1
      if Nic.IPEnabled then
         GetIP = Nic.IPAddress(i)
      end if
   next
End Function 

RE: Map network printers based on workstation IP addresses

CODE --> VBScript

set objNetwork = WScript.CreateObject("WScript.Network")
sIP = GetIP()
If sIP <> "" Then
	
   IPArray = Split(sIP,".")
   ThirdOctet = IPArray(2)

   'Map printer based on octet
   Select Case ThirdOctet
      case "146"
         objNetwork.AddWindowsPrinterConnection "\\nesvr-prt01\!Print drivers\Omaha Printers\add_2nd_flr_printers.bat"
      case "147"
         objNetwork.AddWindowsPrinterConnection "\\nesvr-prt01\!Print drivers\Omaha Printers\add_2nd_flr_printers.bat"
   end Select 
end If


Function GetIP()
   dim NIC1, Nic, StrIP, CompName
   Set NIC1 = GetObject("winmgmts:").InstancesOf("Win32_NetworkAdapterConfiguration")
   For Each Nic in NIC1
      if Nic.IPEnabled then
         GetIP = Nic.IPAddress(i)
      end if
   next
End Function 

Great post? 

I hope that helps.

Regards,

Mark

No trees were harmed in posting this message, however a significant number of electrons were terribly inconvenienced.

Check out my scripting solutions at http://www.thespidersparlor.com/vbscript

Work SMARTER not HARDER.

RE: Map network printers based on workstation IP addresses

Quote (markdmac)

Another way to identify the third octet would be to just split the IPAddress based on the periods
Yep, which is what the OP was doing in their second post... then somehow that changed

Anatec: You need to go line by line through your code and look at what each line is doing:

Line 1: set objNetwork = WScript.CreateObject("WScript.Network")
Line 2: sIP = GetIP()
Line 3: If sIP <> "" Then
Line 4: 	
Line 5:    IPArray = Split(IPAddress,".")
Line 6:    ThirdOctet = IPArray(2) 

In Line 2, you are storing the IP address in a variable called "sIP". But in Line 5, you are running the Split command on a variable called "IPAddress", which does not exist. The result is an empty array and an error on Line 6. You have to be consistent with your variables.

Line 5 should read IPArray = Split(sIP, ".")

RE: Map network printers based on workstation IP addresses

(OP)
Haha.. figured it out after I thought about it. Now with the following code I get an error on line 13 that says "the printer name is invalid." but I think it is because I'm am trying to run a .bat file. I replaced \\nesvr-prt01\!Print drivers\Omaha Printers\add_2nd_flr_printers.bat with \\nesvr-prt01\FLR2_RICOH_1 and it added! My next question is how do I get this to run a batch file? I tried swapping out the following code but didn't have any luck...

CODE --> VBScript

Dim objShell
Set objShell = WScript.CreateObject("WScript.Shell")
objShell.Run "c:\batch\test.cmd" 

RE: Map network printers based on workstation IP addresses

(OP)
Sorry if that was confusing... this is what it looks like now with an error on line 15 stating "the network path was not found."
FYI, "\\nesvr-prt01\!Print drivers\Omaha Printers\add_2nd_flr_printers.bat" is a shared path on our printer server that everyone can access

CODE --> VBScript

Dim objShell
Set objShell = WScript.CreateObject("WScript.Shell")
set objNetwork = WScript.CreateObject("WScript.Network")
sIP = GetIP()
If sIP <> "" Then
	
   IPArray = Split(sIP,".")
   ThirdOctet = IPArray(2)

   'Map printer based on octet
   Select Case ThirdOctet
      case "146"
         objShell.run "\\nesvr-prt01\!Print drivers\Omaha Printers\add_2nd_flr_printers.bat"
      case "147"
         objShell.run "\\nesvr-prt01\!Print drivers\Omaha Printers\add_2nd_flr_printers.bat"
   end Select 
end If


Function GetIP()
   dim NIC1, Nic, StrIP, CompName
   Set NIC1 = GetObject("winmgmts:").InstancesOf("Win32_NetworkAdapterConfiguration")
   For Each Nic in NIC1
      if Nic.IPEnabled then
         GetIP = Nic.IPAddress(i)
      end if
   next
End Function 

RE: Map network printers based on workstation IP addresses

(OP)
I guess I could just manually list out every printer.. just not sure if that would effect performance since it will be a logon script.

RE: Map network printers based on workstation IP addresses

Take a look at my login script FAQ linked above. You should only need to actually map the printer, not run a batch file. When connecting to the shared printer it will download the drivers from the server.

I hope that helps.

Regards,

Mark

No trees were harmed in posting this message, however a significant number of electrons were terribly inconvenienced.

Check out my scripting solutions at http://www.thespidersparlor.com/vbscript

Work SMARTER not HARDER.

RE: Map network printers based on workstation IP addresses


Here is an example of how to add a printer connection to a shared printer.

CODE

Dim objShell
Set objShell = WScript.CreateObject("WScript.Shell")
set objNetwork = WScript.CreateObject("WScript.Network")
sIP = GetIP()
If sIP <> "" Then
	
   IPArray = Split(sIP,".")
   ThirdOctet = IPArray(2)

   'Map printer based on octet
   Select Case ThirdOctet
      case "146"
         objNetwork.AddWindowsPrinterConnection "\\Server\HP5si"
      case "147"
         objNetwork.AddWindowsPrinterConnection "\\Server\HP6si"
   end Select 
end If


Function GetIP()
   dim NIC1, Nic, StrIP, CompName
   Set NIC1 = GetObject("winmgmts:").InstancesOf("Win32_NetworkAdapterConfiguration")
   For Each Nic in NIC1
      if Nic.IPEnabled then
         GetIP = Nic.IPAddress(i)
      end if
   next
End Function 

I hope that helps.

Regards,

Mark

No trees were harmed in posting this message, however a significant number of electrons were terribly inconvenienced.

Check out my scripting solutions at http://www.thespidersparlor.com/vbscript

Work SMARTER not HARDER.

RE: Map network printers based on workstation IP addresses

(OP)
Yes Mark that helps a lot thank you... I do have 1 last question. I will attach 1 floor of printers, I have another 2 to add... I want to make it so that it will remove other floor printers if a PC is connect to a new floor. (Ex, there a PC on floor 1 that moves to floor 2... will remove floor 1 & 3 printers and add floor 2 printers.) this seems like it will be a bit cumbersome as a logon script. Do you have any recommendations how to make this run faster or a better solution to my issue? Thank you

CODE --> VBScript

set objNetwork = WScript.CreateObject("WScript.Network")
sIP = GetIP()
If sIP <> "" Then
	
   IPArray = Split(sIP,".")
   ThirdOctet = IPArray(2)

   'Map printer based on octet
   Select Case ThirdOctet
      case "146"
  	 objNetwork.AddWindowsPrinterConnection "\\NESVR-PRT01\FLR2_HP_CLR1"
	 objNetwork.AddWindowsPrinterConnection "\\NESVR-PRT01\FLR2_RICOH_1"
	 objNetwork.AddWindowsPrinterConnection "\\NESVR-PRT01\FLR2_RICOH_2"
	 objNetwork.AddWindowsPrinterConnection "\\NESVR-PRT01\FLR2_RICOH_3"
	 objNetwork.AddWindowsPrinterConnection "\\NESVR-PRT01\FLR2_RICOH_4"
	 objNetwork.RemoveWindowsPrinterConnection "\\NESVR-PRT01\FLR1_HP_CLR1"
	 objNetwork.RemoveWindowsPrinterConnection "\\NESVR-PRT01\FLR1_RICOH_1"
	 objNetwork.RemoveWindowsPrinterConnection "\\NESVR-PRT01\FLR1_TOSHIBA_1"
	 objNetwork.RemoveWindowsPrinterConnection "\\NESVR-PRT01\FLR3_HP_CLR3"
	 objNetwork.RemoveWindowsPrinterConnection "\\NESVR-PRT01\FLR3_RICOH_1"
	 objNetwork.RemoveWindowsPrinterConnection "\\NESVR-PRT01\FLR3_RICOH_2"
	 objNetwork.RemoveWindowsPrinterConnection "\\NESVR-PRT01\FLR3_RICOH_3"
      case "147"
         objNetwork.AddWindowsPrinterConnection "\\NESVR-PRT01\FLR2_HP_CLR1"
	 objNetwork.AddWindowsPrinterConnection "\\NESVR-PRT01\FLR2_RICOH_1"
	 objNetwork.AddWindowsPrinterConnection "\\NESVR-PRT01\FLR2_RICOH_2"
	 objNetwork.AddWindowsPrinterConnection "\\NESVR-PRT01\FLR2_RICOH_3"
	 objNetwork.AddWindowsPrinterConnection "\\NESVR-PRT01\FLR2_RICOH_4"
	 objNetwork.RemoveWindowsPrinterConnection "\\NESVR-PRT01\FLR1_HP_CLR1"
	 objNetwork.RemoveWindowsPrinterConnection "\\NESVR-PRT01\FLR1_RICOH_1"
	 objNetwork.RemoveWindowsPrinterConnection "\\NESVR-PRT01\FLR1_TOSHIBA_1"
	 objNetwork.RemoveWindowsPrinterConnection "\\NESVR-PRT01\FLR3_HP_CLR3"
	 objNetwork.RemoveWindowsPrinterConnection "\\NESVR-PRT01\FLR3_RICOH_1"
	 objNetwork.RemoveWindowsPrinterConnection "\\NESVR-PRT01\FLR3_RICOH_2"
	 objNetwork.RemoveWindowsPrinterConnection "\\NESVR-PRT01\FLR3_RICOH_3"
   end Select 
end If


Function GetIP()
   dim NIC1, Nic, StrIP, CompName
   Set NIC1 = GetObject("winmgmts:").InstancesOf("Win32_NetworkAdapterConfiguration")
   For Each Nic in NIC1
      if Nic.IPEnabled then
         GetIP = Nic.IPAddress(i)
      end if
   next
End Function 

RE: Map network printers based on workstation IP addresses

Are your IPs assigned by floor? How can you identify where a computer is located? Is there a floor designation in the computer name or registry?

I hope that helps.

Regards,

Mark

No trees were harmed in posting this message, however a significant number of electrons were terribly inconvenienced.

Check out my scripting solutions at http://www.thespidersparlor.com/vbscript

Work SMARTER not HARDER.

RE: Map network printers based on workstation IP addresses

(OP)
You can identify where a computer is by the IP address. Each floor has 2 subnets designated to it differentiated by the 3rd octet.

10.231.144 & 145 = 1st floor
10.231.146 & 147 = 2nd floor
10.231.148 & 149 = 3rd Floor

RE: Map network printers based on workstation IP addresses

You can consolidate by specifying the multiple subnets per floor.

CODE

case "146","147" 

If you move a computer and the IP changes, the login script should add the printers in as needed.

You may need to clear the existing printers before adding them to ensure things stay clean, or you can make it part of your move process.

I hope that helps.

Regards,

Mark

No trees were harmed in posting this message, however a significant number of electrons were terribly inconvenienced.

Check out my scripting solutions at http://www.thespidersparlor.com/vbscript

Work SMARTER not HARDER.

RE: Map network printers based on workstation IP addresses

(OP)
So this is the most ideal code for this situation? This seems like it would clear the existing printers before adding the new ones, correct?

CODE --> VBScript

case "146","147"
	 objNetwork.RemoveWindowsPrinterConnection "\\NESVR-PRT01\FLR1_HP_CLR1"
	 objNetwork.RemoveWindowsPrinterConnection "\\NESVR-PRT01\FLR1_RICOH_1"
	 objNetwork.RemoveWindowsPrinterConnection "\\NESVR-PRT01\FLR1_TOSHIBA_1"
	 objNetwork.RemoveWindowsPrinterConnection "\\NESVR-PRT01\FLR3_HP_CLR3"
	 objNetwork.RemoveWindowsPrinterConnection "\\NESVR-PRT01\FLR3_RICOH_1"
	 objNetwork.RemoveWindowsPrinterConnection "\\NESVR-PRT01\FLR3_RICOH_2"
	 objNetwork.RemoveWindowsPrinterConnection "\\NESVR-PRT01\FLR3_RICOH_3"
  	 objNetwork.AddWindowsPrinterConnection "\\NESVR-PRT01\FLR2_HP_CLR1"
	 objNetwork.AddWindowsPrinterConnection "\\NESVR-PRT01\FLR2_RICOH_1"
	 objNetwork.AddWindowsPrinterConnection "\\NESVR-PRT01\FLR2_RICOH_2"
	 objNetwork.AddWindowsPrinterConnection "\\NESVR-PRT01\FLR2_RICOH_3"
	 objNetwork.AddWindowsPrinterConnection "\\NESVR-PRT01\FLR2_RICOH_4" 

RE: Map network printers based on workstation IP addresses

Yes that will work or you can remove all current network printers without namign them like this:

CODE

Set WSHPrinters = WSHNetwork.EnumPrinterConnections
For LOOP_COUNTER = 0 To WSHPrinters.Count - 1 Step 2
'To remove only networked printers use this If Statement
	If Left(WSHPrinters.Item(LOOP_COUNTER +1),2) = "\\" Then
	  WSHNetwork.RemovePrinterConnection WSHPrinters.Item(LOOP_COUNTER +1),True,True
	End If
'To remove all printers incuding LOCAL printers use this statement and comment out the If Statement above
'WSHNetwork.RemovePrinterConnection WSHPrinters.Item(LOOP_COUNTER +1),True,True
Next 

I hope that helps.

Regards,

Mark

No trees were harmed in posting this message, however a significant number of electrons were terribly inconvenienced.

Check out my scripting solutions at http://www.thespidersparlor.com/vbscript

Work SMARTER not HARDER.

RE: Map network printers based on workstation IP addresses

(OP)
Your way will probably be a more efficient way to remove all the networked printers... I'm just confused where to put that in the following code. I've tried a variety of different options.. can't seem to figure it out :\

CODE --> VBScript

set objNetwork = WScript.CreateObject("WScript.Network")
sIP = GetIP()
If sIP <> "" Then
	
   IPArray = Split(sIP,".")
   ThirdOctet = IPArray(2)

   'Map printer based on octet
   Select Case ThirdOctet
      case "146","147"
  	 objNetwork.AddWindowsPrinterConnection "\\NESVR-PRT01\FLR2_HP_CLR1"
	 objNetwork.AddWindowsPrinterConnection "\\NESVR-PRT01\FLR2_RICOH_1"
	 objNetwork.AddWindowsPrinterConnection "\\NESVR-PRT01\FLR2_RICOH_2"
	 objNetwork.AddWindowsPrinterConnection "\\NESVR-PRT01\FLR2_RICOH_3"
	 objNetwork.AddWindowsPrinterConnection "\\NESVR-PRT01\FLR2_RICOH_4"
   end Select 
end If

Function GetIP()
   dim NIC1, Nic, StrIP, CompName
   Set NIC1 = GetObject("winmgmts:").InstancesOf("Win32_NetworkAdapterConfiguration")
   For Each Nic in NIC1
      if Nic.IPEnabled then
         GetIP = Nic.IPAddress(i)
      end if
   next
End Function 

RE: Map network printers based on workstation IP addresses

Put it under here:
set objNetwork = WScript.CreateObject("WScript.Network")

Please note I copied that from my login script FAQ. Change WSHNetwork to match your code which is using objNetwork.

I hope that helps.

Regards,

Mark

No trees were harmed in posting this message, however a significant number of electrons were terribly inconvenienced.

Check out my scripting solutions at http://www.thespidersparlor.com/vbscript

Work SMARTER not HARDER.

RE: Map network printers based on workstation IP addresses

Can you not use gpmc use item level targeting and select Ip address range

MCSE NT to 2012, MCITP:EA/SA, MCSA, MCDBA, MCTS, MCP+I, MCP

RE: Map network printers based on workstation IP addresses

Well, hopefully you learned something about scripting even if you won't use it.

I hope that helps.

Regards,

Mark

No trees were harmed in posting this message, however a significant number of electrons were terribly inconvenienced.

Check out my scripting solutions at http://www.thespidersparlor.com/vbscript

Work SMARTER not HARDER.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close