Re: Setting Printers Based On Room Location
Quote:
Originally Posted by kingswood
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)?
I put mine in netlogon and browse for it in GP. I think there is a default location where scripts go otherwise 'per policy'. I'm sure you could put it pretty much where you wanted, but you'd have to get the permissions right - obviously sorted if it goes in netlogon!
Quote:
Originally Posted by kingswood
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??
Exactly right, but I think you'll find you need to put your script in the Logon Scripts policy under User Config (but for the machine's policy!)
:)
Andy.
1 Attachment(s)
Re: Setting Printers Based On Room Location
Here's my updated script which checks the first four characters of the computer name. Simply change the characters that are searched for in the case statement and the printer shares accordingly (more can be added before the 'case else' statement).
I tend to keep the script in the NETLOGON share and it is applied by GPO on the Users OU (inside which I have OUs for staff and pupils). The script should be run as a login script - not a startup script. Don't run it as an admin or on the print server as all the printers will disappear from your server!
Re: Setting Printers Based On Room Location
Thanks to all for the replies- I'll be trying Ric's script out today or tomorrow.
Paul :-)
Re: Setting Printers Based On Room Location
Quote:
Originally Posted by Ric_
Here's my updated script which checks the first four characters of the computer name. Simply change the characters that are searched for in the case statement and the printer shares accordingly (more can be added before the 'case else' statement).
I tend to keep the script in the NETLOGON share and it is applied by GPO on the Users OU (inside which I have OUs for staff and pupils). The script should be run as a login script - not a startup script. Don't run it as an admin or on the print server as all the printers will disappear from your server!
We would be willing to try this, however, does the VB script delete all of the network printers if a teacher was to log onto their laptop where the printers are all set up (i.e. networked photocopiers). Also does this script take very long to run?
We are currently using the rundll method but have found that this sometimes does not work properly and want to see if there is anything else out there.
Re: Setting Printers Based On Room Location
have never had any problems with the rundll method using a batch script that features lots of sections like:
if %computername:~0,3% == A8- (
rundll32 printui.dll,PrintUIEntry /in /n \\print1\A8Laser
rundll32 printui.dll,PrintUIEntry /y /n \\print1\A8Laser /q
echo A8 Printer connected.
goto END
)
ideally best 2 have 2 identical print servers so if there's a problem with one u can just alter the batch script so printers are mapped from the other.
Re: Setting Printers Based On Room Location
An old Microsoft NT4 tool exists called Con2Prt.exe which connects and disconnects printers via a DOS command line command.
Using this utility as described will provide a user with a list of printers available to the workstation they are logging on at. The list of available printers and the default printer can be defined per machine usually on a room basis.
You just put a variable on it and its a doddle to use - here is a good link with instructions and how to get it
http://www.rangersuite.com/support/k...%20con2prt.exe
Re: Setting Printers Based On Room Location
Quote:
Originally Posted by browolf
have never had any problems with the rundll method using a batch script that features lots of sections like:
if %computername:~0,3% == A8- (
rundll32 printui.dll,PrintUIEntry /in /n \\print1\A8Laser
rundll32 printui.dll,PrintUIEntry /y /n \\print1\A8Laser /q
echo A8 Printer connected.
goto END
)
ideally best 2 have 2 identical print servers so if there's a problem with one u can just alter the batch script so printers are mapped from the other.
I like this method! How do you find the switches for that command?
Re: Setting Printers Based On Room Location
I've got a really good script that will do exactly this, you can add the variable that says if the computer name starts with "xxx" then add a printer "xyz" as the default
Will send it on Monday when I get back into work
Regards
Matt
Re: Setting Printers Based On Room Location
@luke213: Simply edit the script so that it behaves differently for computers named <whatever> and have it not run the remove printers section. An if.. not statement should do the trick.
Re: Setting Printers Based On Room Location
First thing to say is Hi! (First post)
I just thought I would make a couple of comments as I used a similar script where I work.
I spent a number of hours when I first used a vbs script to add printers trying to work out why they appeared but didn't always work. If you are only a domain user, you are allowed to add printers via a vbs script, but you aren't allowed to install the drivers. If this is the case, you get attached to the network printer but can't actually print, you get a nice error instead.
The way I get around printer drivers is to run a slighly modified version also as the startup script. As this script runs as system, it is allowed to install new drivers, then when the user logs in, they don't need to install drivers and it all works.
One other thing I would mention is that I have "wsh.sleep 5000" between adding a printer and making it default, sometimes it takes a second or two to finish adding the printer, and with multiple printers the default command sometimes is run before the printer exists.
I also have a WMI script that removes the Microsoft Document imager if anyone is interested, you can't seem to access it via vbs as it has a funny name.
David
Re: Setting Printers Based On Room Location
@DMcCoy: Would love the WMI script ;)
Re: Setting Printers Based On Room Location
Quote:
Originally Posted by Ric_
@DMcCoy Would love the WMI script ;)
you can do it within the vbs file, but again, this one has to run as the startup script (in fact I guess it can be a seperate startup script on its own).
I think this is the relevant bit, test it first :)
Code:
strComputer = "."
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colInstalledPrinters = objWMIService.ExecQuery ("SELECT * FROM Win32_Printer")
For Each objPrinter in colInstalledPrinters
IF objPrinter.Name = "Microsoft Office Document Image Writer" THEN
objPrinter.Delete_
END IF
Next
mind the word wrap
Re: Setting Printers Based On Room Location
what's this bit: "\root\cimv2" ?
Re: Setting Printers Based On Room Location
the WMI management root path.
Re: Setting Printers Based On Room Location
which is... [hehe]
Is that it? is that the path? - not a reference to any specific path or machine - but syntax for the WMI root path generically?