?
Solved

Printer Mapping by Subnet

Posted on 2006-11-25
9
Medium Priority
?
2,648 Views
Last Modified: 2010-01-12
After a user logs into and authenticates to a particular physical location (all one subnet...10.203.X.X), can a separate script be run to install all of the printers at that location? In that way, any person logging into a computer on that subnet, could utilize any printer at that location.

Computers on this subnet authenticate to one of 2 DC's. Only computers on this subnet authenticate to these 2 DC's. If that info is helpful.
0
Comment
Question by:amfiore
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 3
9 Comments
 
LVL 40

Expert Comment

by:Fatal_Exception
ID: 18012527
I might look at this from a different perspective... being that I would place those users in a separate OU and run the printer script using a GPO on that OU...  JMHO...
0
 

Author Comment

by:amfiore
ID: 18012560
Here's the issue. There are over 6000 users who intermittently go to this location for classes, etc. They need to print when they are there and cannot. But, I wouldn't want them to have access to those printers all the time. Some users print confidential materials, and forgot to "pick" the correct printer.
0
 
LVL 40

Accepted Solution

by:
Fatal_Exception earned 1000 total points
ID: 18012760
I take it that some users have portable laptops, and you cannot assign printers based on the computers themselves..?

Then you might be able to use this:  (I forget where I got it, but have it in one of my knowledge bases)...  :)

Create a single login script that checks the Subnet that the user is on and, based upon the Subnet (the 3rd octet in the IP Address) map a network drive or printer specific to that location.

Below is a simple batch file that determines the Subnet and maps a drive based on the Subnet.

 @echo off
cls

REM LOGIN.BAT
REM Default Login Script
REM
REM NOTE: When calling other batch files from this login script,
there are two important things to keep in mind.
REM       - always be sure to use 'call' before the batch file name
REM       - never use 'exit' in the batch file that you are calling
REM       Failure to keep these things in mind will cause this login
script to terminate after calling.
REM       the other batch file.

if exist c:tempip.tmp del c:tempip.tmp

echo Running Windows Login Script...
echo.
echo Temporarily removing F drive...
echo.
net use f: /delete

REM Determine Subnet, do things based on SUBNET
REM ALL USERS section is where things go that need to happen for all
users regardless of subnet.
REM
for /f "tokens=2 delims=:" %%i in ('ipconfig ^| find /i "IP Address"')
do set IP=%% iecho %IP% >> c:tempip.tmp
for /f "tokens=3 delims=." %%j in (c:tempip.tmp) do set SUBNET=%%j

if %SUBNET%==16 goto 16_SUBNET
if %SUBNET%==100 goto 100_SUBNET
if %SUBNET%==250 goto 250_SUBNET
goto ALL_USERS

:16_SUBNET
net use F: \{16_subnet_server}share
echo Welcome to the 16 subnet!
goto ALL_USERS

:100_SUBNET
net use F: \{100_subnet_server}share
echo Welcome to the 100 subnet!
goto ALL_USERS

:250_SUBNET
net use F: \{250_subnet_server}share
echo Welcome to the 250 subnet!
goto ALL_USERS

:ALL_USERS
REM Use this section to perform functions that pertain to all users
goto END

:END
0
Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

 
LVL 40

Expert Comment

by:Fatal_Exception
ID: 18012762
BTW:  that script maps a drive, but you can change it to map printers...
0
 

Author Comment

by:amfiore
ID: 18012810
I found this on experts-exchange, but i'm new to scripting and really don't understand it. Where do I customize this? anything you can do to help would be appreciated.

All I am trying to do is if a user is in 10.203.x.x - map to

rundll32 printui.dll,PrintUIEntry /in /n\\sps-printserv\HS-COLOR
rundll32 printui.dll,PrintUIEntry /in /n\\sps-hs-apps\Rm-259-office
rundll32 printui.dll,PrintUIEntry /in /n\\sps-hs-apps\Rm-259-color
rundll32 printui.dll,PrintUIEntry /in /n\\sps-hs-apps\Rm-427-lab
rundll32 printui.dll,PrintUIEntry /in /n\\sps-hs-apps\Rm-421-office
rundll32 printui.dll,PrintUIEntry /in /n\\sps-hs-apps\Rm-400-office
0
 
LVL 40

Expert Comment

by:Fatal_Exception
ID: 18013103
/in = add network printer connection
/n = PrinterName

But, I came across a nice script that was posted in the Petri forums:

http://www.petri.co.il/forums/archive/index.php?t-7759.html

BAT FILE:

===========copy==============

:GetIP
:: IP for primary adapter
setlocal
for /f "delims=: tokens=1-2" %%c in ('ipconfig /all ^| find "IP Address"') do set GetIP=%%d
endlocal & set GetIP=%GetIP:~1%

start /w logon.vbs %GetIP%



VbScript: logon.vbs


Option Explicit

Dim MyIP, SubNet, IpChunk

On Error Resume Next

Set wshNetwork = CreateObject("WScript.Network")

MyIP = Wscript.Arguments.item(0)

IpChunk = Split(MyIP,".")
SubNet = CInt(IpChunk(2))

'Assuming IP's 192.168.1.0, 192.168.2.0, 192.168.3.0....
If SubNet = 1 Then Floor1
If SubNet = 2 Then Floor2
If SubNet = 3 Then Floor3

Public Sub Floor1
'add your code here
wshNetwork.MapNetworkDrive "M:", "\\Server\NET-APPS"
wshNetwork.AddWindowsPrinterConnection "\\Server\HPLJ4200-flr1"
wshNetwork.RemovePrinterConnection "\\Server\HPLJ4200-flr2"
wshNetwork.RemovePrinterConnection "\\Server\HPLJ4200-flr3"
End Sub

Public Sub Floor2
wshNetwork.MapNetworkDrive "M:", "\\Server\NET-APPS"
wshNetwork.AddWindowsPrinterConnection "\\Server\HPLJ4200-flr2"
wshNetwork.RemovePrinterConnection "\\Server\HPLJ4200-flr1"
wshNetwork.RemovePrinterConnection "\\Server\HPLJ4200-flr3"
End Sub

Public Sub Floor3
wshNetwork.MapNetworkDrive "M:", "\\Server\NET-APPS"
wshNetwork.AddWindowsPrinterConnection "\\Server\HPLJ4200-flr3"
wshNetwork.RemovePrinterConnection "\\Server\HPLJ4200-flr1"
wshNetwork.RemovePrinterConnection "\\Server\HPLJ4200-flr2"
End Sub

Wscript.quit
0
 
LVL 40

Expert Comment

by:Fatal_Exception
ID: 18013111
BTW:  I am not well versed with doing my own scripting either...  Lucky I have a separate programming dept. that I can lean on with this at my corp. offices..  :)
0
 

Author Comment

by:amfiore
ID: 18014373
Surprisingly, I got the first script to work. Thank you very much. I'll try this one as well.
0
 
LVL 40

Expert Comment

by:Fatal_Exception
ID: 18015238
Great news!  Am going to try it myself as soon as I get back in the office..  and thank you..

FE
0

Featured Post

Veeam Task Manager for Hyper-V

Task Manager for Hyper-V provides critical information that allows you to monitor Hyper-V performance by displaying real-time views of CPU and memory at the individual VM-level, so you can quickly identify which VMs are using host resources.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever set up your wireless router at home or in the office to find that you little pop-up bubble in the bottom right-hand corner of Windows read "IP Conflict - One of more computers on the network have been assigned the following IP address"…
Enterprise networks where VoIP phones have been deployed frequently use port configurations that allow both a computer and an IP phone to be plugged into the same switch port but use different VLANs. On Cisco equipment I'm referring to the "native V…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question