Solved

Printer Mapping by Subnet

Posted on 2006-11-25
9
2,604 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 250 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
Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

 
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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

A common practice in small networks is making file sharing easy which works extremely well when intra-network security is not an issue. In essence, everyone, that is "Everyone", is given access to all of the shared files - often the entire C: drive …
Trying to figure out group policy inheritance and which settings apply where can be a chore.  Here's a very simple summary I've written which might help.  Keep in mind, this is just a high-level conceptual overview where I try to avoid getting bogge…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

734 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