Ric_ Posted August 25, 2005 Posted August 25, 2005 I thought that I'd already posted this but obviously not This is a VBScript for adding printers based on the computername. You will notice that there is an if statement checking to see if the computer is called svrts1. This is so that the script will work in TS/Citrix. Feel free to use this script and any of its contents - obviously you do so at your own risk!!! We shall have no theft of intellectual property (i.e. don't try and sell it!). DO NOT RUN THE SCRIPT ON YOUR PRINT SERVER!!! I may be enhancing this slightly so check back soon! printers_185.vbs
mac_shinobi Posted August 30, 2005 Posted August 30, 2005 Not sure how much use this is to you but a good site I have come across is this one : http://www.computerperformance.co.uk/vbscript/index.htm Has a lot of good examples with explanations etc btw good vbscript ya got there
Ric_ Posted January 18, 2006 Author Posted January 18, 2006 Here is my current incarnation of the script (as promised)... not sure how much it has changed though.printers_208.vbs
Gatt Posted January 23, 2006 Posted January 23, 2006 Ric just tried to implement your printer script here, but got some problems Main one is that our Pc's are named room#-pc# eg - 01-13 is computer 13 in room 01 However these rooms are not being mapped to their printers the only one that works fine is the LRC computers I'm assuming its the "LCase(WSHNetwork.Computername)" line - as i had to change this to UCase to get it working at first, but I cannot get it working for the main Classrooms I have tried removing the LCase() from arund WshNetwork.Computername with no joy the only way I can get it to work was to rename one of the computers to begin with a letter, but this will be time consuming to go round all the PC's to rename them.
ChrisH Posted January 23, 2006 Posted January 23, 2006 change Select Case (Left(computerName, 4)) Case "rm31" so it looks like: Select Case (Left(computerName, 2)) Case "01" So its only looking at the first two letters/numbers in your computer name. That way it will only pick up the room number eg 01 and not 01-1
Ric_ Posted January 23, 2006 Author Posted January 23, 2006 ChrisH is correct, you need to select how many characters you will inspect. If I understand your post, it should read: Select Case (Left(computerName, 6)) Case "room01"... the LCase() statement forces the computername to lowercase si all your case statements should be in lowercase. I found that, depending upon the config of the computer, sometimes the computername is capitalised and sometimes it is not. I could have just as easily used uppercase.
ChrisH Posted January 23, 2006 Posted January 23, 2006 I had to read it several times but he needs the first two digits his rooms are like so 01-1 01-2 01-3 02-1 02-2 02-3
Geoff Posted January 23, 2006 Posted January 23, 2006 Select Case (Right(Left(computerName, 6), 2)) Case "01" ........ Case "02" ........ etc
apeo Posted January 23, 2006 Posted January 23, 2006 Just thought I would add this in as a different view on the same principle, here we do have a naming convention to identify the location of the computer but we also use Environment Variable to identify location. This way you don’t have to strip the computer name to find the location but it does mean you will have to put in an environment variable on each computer.printers_195.vbs
Gatt Posted January 23, 2006 Posted January 23, 2006 Ok got it sorted - instead of looking at the 1st 2 characters I increased it to 3!! D'oh!
mac_shinobi Posted January 25, 2006 Posted January 25, 2006 With this script you can dim each room you have on one line or you can use constants ie const ICT1 = "Printer_Share_Name" Also the function can be neatend up so that it includes the \\ symbols so all you have to type into the function call is something like so : call AddPrinter(Server_Name,Room_Name) Where Server_Name would be svr3 and Room_Name would be the variable for your printer share name which in this case as per above would be ICT1 hence the function call would be : call AddPrinter(svr3,ICT1) At this point in time the function does not include the \\ symbols so when you enter the server name include the server name in double quotes along with the \\ symbols as relevant ie call AddPrinter("\\svr3\",ICT1) I figured since the add printer and make default printer commands and all of that were being constantly re used it would be a better idea to add them into a function and call them as needed and pass the servername and sharename to the function, I could of used the share names directly but then I didnt want to get confused between which printer sharename was related to which room hence the assignments of Share name to the variable room names ( If that makes sense ) Anyway hopefully this helps out a little bit, what I would like to see is an example of how to determine the servername so that it is not manually required to type that in so it can be assigned to a variable and then used within the function call.
Wiseman82 Posted January 25, 2006 Posted January 25, 2006 I created a utility for this when I was working as a technician for a college. We installed printers based on the room name - pc's were named roomid-computerid. I guess most of you guys are using similar naming conventions. http://www.wisesoft.co.uk/scriptbuilder.php I created this utility to ensure I wasn't the only person able to edit the printer mapping script.
TimH Posted February 12, 2006 Posted February 12, 2006 I/we use a script which matches machine AD location with printer AD location. For kids they get the one local printer, for staff they get all printers but with the local one set as default. It does away with the need for all the "select/case" stuff and the need to tweak the script for new printers/rooms. Could obviously be tweaked to handle multiple printers in one location or handle multiple locations for a PC - maybe use "description" field in AD. I've just doctored the scripts to make them know where they are (domain-wise - removed LDAP path / DNS domain name for our network), hopefully I didn't break anything in the process. Timkidlogon.vbsstafflogon.vbs
mac_shinobi Posted February 24, 2006 Posted February 24, 2006 ok tried to download your utility wiseman82 but it is coming back with a usernamd / password prompt. Maybe you can email me scriptbuilder.exe or give me a username and password to download it ?
apeo Posted February 24, 2006 Posted February 24, 2006 I think you need to register to download stuff.. its free and there are other utils that may be worth looking at so might be worth registering.
mac_shinobi Posted February 24, 2006 Posted February 24, 2006 Didnt realise that , was on a lunch break and just wanted to download them lol.
Ric_ Posted June 21, 2006 Author Posted June 21, 2006 BUMP! Some people have missed this recently and may find it useful.
timbo343 Posted January 10, 2007 Posted January 10, 2007 in this script is there a way to delete local printers??? Also, im in the market for a decent VBscript combined with AD book, can anyone recommend any? Tim
Geoff Posted January 10, 2007 Posted January 10, 2007 Just remove this line: if Left(oPrinters.Item(i), 3) <> "lpt" And Left(oPrinters.Item(i), 3) <> "usb" then and it'll nuke local printers.
timbo343 Posted January 11, 2007 Posted January 11, 2007 ok, ive removed that line, but nothing seems to be happening, is this correct: Select Case (computerName) Case "pand" ' Delete Printer For i = 0 to oPrinters.Count - 1 step 2 On Error Resume Next wshNetwork.RemovePrinterConnection oPrinters.Item(i+1), true, true Next End Select Im sure im doing something wrong somewhere
Geoff Posted January 11, 2007 Posted January 11, 2007 What sort of printer connection are you trying to remove?
Geoff Posted January 11, 2007 Posted January 11, 2007 The standard script will remove those, you don't need to do anything fancy.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now