Scripts Thread, Setting Printers Based On Room Location in Coding and Web Development; Hello All,
Does anyone have any scripts that set printers based on room location.
My Scenario:
We have 6 IT ...
-
3rd September 2005, 07:39 AM #1 Setting Printers Based On Room Location
Hello All,
Does anyone have any scripts that set printers based on room location.
My Scenario:
We have 6 IT Suites in each one a colour laser and mono laser, when a person (does not matter who) logs onto a machine in that room the printers in the will be mapped and made available.
All printers are network'd.
Ideally I would like to set the printers via GPO but have not yet found a way to do this but given time...... ;-)
Any pointers would be cool.
Oh Yeah, each machine have a unique name and the computer description has the following "Room XX - PC XX"
-
-
IDG Tech News
-
3rd September 2005, 11:15 AM #2 Re: Setting Printers Based On Room Location
About five threads down in this forum...
Printer Scripts Thread
-
-
3rd September 2005, 05:30 PM #3 Re: Setting Printers Based On Room Location
Thanks RobC,
I really need to learn to search....
-
-
4th September 2005, 01:04 AM #4 Re: Setting Printers Based On Room Location
Heh, don't worry about it. BTW, if you get stuck feel free to post. I've hacked Rics script to bits to do what I wanted. I'm sure you'll end up in the same boat.
-
-
4th September 2005, 04:13 PM #5 Re: Setting Printers Based On Room Location
Geoff,
After a heck of alot of digging I have found that the computer description is held in the registry.
I have used Ric's script as a basis and added a registry lookup to get the computer description (ours are set as Room XX - PC XX, and PC names are all unique as per the counties naming convention).
Anyhow as we are only reading a reg key no special permissions are required so finally (after about 3 weeks of hunting) I can get the printers sorted ;-)
-
-
4th September 2005, 08:31 PM #6 Re: Setting Printers Based On Room Location
Hey ICT NUT, Any chance you can post back with the working script when you get it tweaked and finished, if thats ok ?
As I'm sure that would be useful
to some degree
-
-
4th September 2005, 10:11 PM #7 Re: Setting Printers Based On Room Location
@ICTNUT: Stick the modification into the post with the script so that others may find it more easily
-
-
5th September 2005, 08:25 AM #8 Re: Setting Printers Based On Room Location
You can query AD for a description as well.
-
-
5th September 2005, 08:36 AM #9 Re: Setting Printers Based On Room Location
@ChrisH: I agree you can query the AD but that requires special permissions and although you can impersonate in some cases a username and password must be supplied. Not happy about providing those in plain text.
@Ric_ & Gecko: I am testing the script within the school now and will post up later today.
-
-
5th September 2005, 10:01 AM #10 Re: Setting Printers Based On Room Location
I havent tested it but I would have thought it would have worked in the context of a log on script. My log in script querys ad for group membership with no problem. It must be different for computer objects I take it?
-
-
5th September 2005, 11:02 AM #11 Re: Setting Printers Based On Room Location
I haven't read the links but this is a quick and basic way to get a network printer added.
If you type
%systemroot%\system32\rundll32.exe printui.dll,PrintUIEntry /ga /n \\SERVER_NAME\PRINTER_NAME
in a command prompt it will add the printer for all users who log on to that PC.
It does mean you need to do it on each computer and redo everytime you change the share name but is simple enough to add that line to a logon script, for each room (OU) of computers throgh Group Policy and AD, if you want.
-
-
5th September 2005, 11:12 AM #12
- Rep Power
- 0
Re: Setting Printers Based On Room Location
WE use a VBS script. Specifies a specific printer based on the room and machine name.
Machine name a1-01-XX (xx being the machine number in room A1-01)
To see the properly better paste in to notepad.
rem Printer Mapping Script
Const NetworkMapped = "\\"
On Error Resume Next
Set objNetwork = CreateObject("WScript.Network")
Set colPrinters = objNetwork.EnumPrinterConnections
For i = 0 to colPrinters.Count -1 Step 2
strPrinterName = colPrinters.Item(i)
strPrinterUNC = colPrinters.Item (i + 1)
If Left(strPrinterUNC,2) = NetworkMapped Then objNetwork.RemovePrinterConnection(strPrinterUNC)
Next
'And now to map the required printers
'Capture the Computer name, take the first 5 characters to determine the classroom
'Then map the relevant printers for that classroom
strComputerName = Left(objNetwork.ComputerName, 5)
Select Case strComputerName
Case "A1-01"
bjNetwork.AddWindowsPrinterConnection "\\servername\printername"
objNetwork.SetDefaultPrinter "\\servername\printername"
End Select
If you need add more insert more lines add them in before the end select command. The number 5 specifies the number of characters to use from the start of the name. So 3 would pick up in our case "A1-"
Hope this helps
-
-
10th September 2005, 11:32 PM #13 Re: Setting Printers Based On Room Location

Originally Posted by
thom I haven't read the links but this is a quick and basic way to get a network printer added.
If you type
%systemroot%\system32\rundll32.exe printui.dll,PrintUIEntry /ga /n \\SERVER_NAME\PRINTER_NAME
in a command prompt it will add the printer for all users who log on to that PC.
It does mean you need to do it on each computer and redo everytime you change the share name but is simple enough to add that line to a logon script, for each room (OU) of computers throgh Group Policy and AD, if you want.
This is roughly what I use - but I put a little txt file on each PCs C: drive and then set the printer depending on what the name of the txt file is - so for example in the IT Suite its IT.txt, and the printer line does an IF EXIST (I think) and runs if the name matches - so theres a bat file that runs through about 30 printers at login - but its very quick. You can add the /y argument to set as default too.
See - http://www.robvanderwoude.com/index.html
-
-
11th September 2005, 11:15 AM #14
- Rep Power
- 0
Re: Setting Printers Based On Room Location
I'd use the method mentioned above with the printui.dll
put all yout workstations in OUs by Room
On the workstation policy (computer configuration) / windows settings / Scripts / Startup script
add a batch file with the relevant printers for that room, using the printui.dll method.
All you need to do to give a computer the right printers is move it into the relevant OU. All the users that logon will get printers specific to that room.
-
-
12th October 2005, 06:59 AM #15 Re: Setting Printers Based On Room Location
OK. These posts are really great- we have some VB scripts running (kind of) and set up by CSE engineers in the past; there's a utility we have in their software that sets these to autorun at login. They worked until last week, and now they sometimes work and sometimes don't. Pathetic really.
Not being a scripter myself, could someone tell me where to put Ric's excellent script so that I can modify it and test it? I know Group Policy pretty well and I'm aware that logon scripts can go in the "Startup Script" section, but once in my SYSVOL/Scripts folder do I merely browse for the file in the GPO or paste the actual contents in there (as I was told to do this week)?
Basically I want the script to check the first 4 letters of the location and choose a default printer from there (e.g. ICT 6 ICT 5 etc etc). Am I right in assuming that since Ric's script chooses the default location based on station name that I could drop it in at the top-level of the Stations OU we have rather than appying it to each OU??
/Ramble
Thanks!
Paul
-
SHARE:
Similar Threads
-
By projector1 in forum Windows
Replies: 50
Last Post: 19th May 2008, 12:24 PM
-
By danIT in forum Downloads
Replies: 131
Last Post: 7th November 2007, 11:20 AM
-
By NeoNemesis in forum Windows
Replies: 11
Last Post: 6th August 2007, 08:03 AM
-
By originofsymmetry in forum Network and Classroom Management
Replies: 3
Last Post: 11th July 2007, 06:02 AM
-
By tosca925 in forum Thin Client and Virtual Machines
Replies: 5
Last Post: 29th June 2006, 07:53 AM
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules