Solved

Printer Mapping by Subnet

Posted on 2006-11-25
9
2,542 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
  • 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
 
LVL 40

Expert Comment

by:Fatal_Exception
ID: 18012762
BTW:  that script maps a drive, but you can change it to map printers...
0
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 

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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Downtime reduced, data recovered by utilizing an Experts Exchange Business Account Challenge The United States Marine Corps employs more than 200,000 active-duty Marines with operations in four continents, all requiring complex networking system…
We recently endured a series of broadcast storms that caused our ISP to shut us down for brief periods of time. After going through a multitude of tests, we determined that the issue was related to Intel NIC drivers on some new HP desktop computers …
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

707 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now