Scripts Thread, A Printer Script in Coding and Web Development; I thought that I'd already posted this but obviously not
This is a VBScript for adding printers based on the ...
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!
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 is correct, you need to select how many characters you will inspect. If I understand your post, it should read:
Code:
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.
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.
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.
Last edited by mac_shinobi; 27th August 2008 at 02:46 PM.
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.
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.
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 ?