Poll: Was this script helpful?

Be advised that this is a public poll: other users can see the choice(s) you selected.

+ Post New Thread
Page 1 of 11 12345 ... LastLast
Results 1 to 15 of 165
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 ...
  1. #1

    Ric_'s Avatar
    Join Date
    Jun 2005
    Location
    London
    Posts
    7,590
    Thank Post
    109
    Thanked 762 Times in 593 Posts
    Rep Power
    180

    A Printer Script

    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!
    Attached Files Attached Files

  2. #2

    mac_shinobi's Avatar
    Join Date
    Aug 2005
    Posts
    9,703
    Thank Post
    3,235
    Thanked 1,043 Times in 965 Posts
    Rep Power
    363

    Re: A Printer Script

    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

  3. #3

    Ric_'s Avatar
    Join Date
    Jun 2005
    Location
    London
    Posts
    7,590
    Thank Post
    109
    Thanked 762 Times in 593 Posts
    Rep Power
    180

    Re: A Printer Script

    Here is my current incarnation of the script (as promised)... not sure how much it has changed though.
    Attached Files Attached Files

  4. #4

    Gatt's Avatar
    Join Date
    Jan 2006
    Posts
    6,658
    Thank Post
    858
    Thanked 646 Times in 429 Posts
    Rep Power
    498

    Re: A Printer Script

    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.

  5. #5
    ChrisH's Avatar
    Join Date
    Jun 2005
    Location
    East Lancs
    Posts
    4,998
    Thank Post
    120
    Thanked 280 Times in 258 Posts
    Rep Power
    106

    Re: A Printer Script

    change
    Code:
    Select Case (Left(computerName, 4))
    	Case "rm31"
    so it looks like:

    Code:
    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

  6. #6

    Ric_'s Avatar
    Join Date
    Jun 2005
    Location
    London
    Posts
    7,590
    Thank Post
    109
    Thanked 762 Times in 593 Posts
    Rep Power
    180

    Re: A Printer Script

    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.

  7. #7
    ChrisH's Avatar
    Join Date
    Jun 2005
    Location
    East Lancs
    Posts
    4,998
    Thank Post
    120
    Thanked 280 Times in 258 Posts
    Rep Power
    106

    Re: A Printer Script

    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

  8. #8

    Geoff's Avatar
    Join Date
    Jun 2005
    Location
    Fylde, Lancs, UK.
    Posts
    11,802
    Thank Post
    110
    Thanked 583 Times in 504 Posts
    Blog Entries
    1
    Rep Power
    224

    Re: A Printer Script

    Code:
    Select Case (Right(Left(computerName, 6), 2))
       Case "01"
          ........
       Case "02"
          ........
    
    etc

  9. #9
    apeo's Avatar
    Join Date
    Sep 2005
    Location
    Lost
    Posts
    1,612
    Thank Post
    95
    Thanked 115 Times in 111 Posts
    Rep Power
    41

    Re: A Printer Script

    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.
    Attached Files Attached Files

  10. #10

    Gatt's Avatar
    Join Date
    Jan 2006
    Posts
    6,658
    Thank Post
    858
    Thanked 646 Times in 429 Posts
    Rep Power
    498

    Re: A Printer Script

    Ok got it sorted - instead of looking at the 1st 2 characters I increased it to 3!!
    D'oh!

  11. #11

    mac_shinobi's Avatar
    Join Date
    Aug 2005
    Posts
    9,703
    Thank Post
    3,235
    Thanked 1,043 Times in 965 Posts
    Rep Power
    363

    Re: A Printer Script

    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.

  12. #12
    Wiseman82's Avatar
    Join Date
    Jan 2006
    Location
    North East
    Posts
    48
    Thank Post
    3
    Thanked 14 Times in 11 Posts
    Rep Power
    21

    Re: A Printer Script

    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.

  13. #13

    Join Date
    Feb 2006
    Location
    Dorset/Hants
    Posts
    87
    Thank Post
    2
    Thanked 13 Times in 10 Posts
    Rep Power
    20

    Re: A Printer Script

    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.

    Tim
    Attached Files Attached Files

  14. #14

    mac_shinobi's Avatar
    Join Date
    Aug 2005
    Posts
    9,703
    Thank Post
    3,235
    Thanked 1,043 Times in 965 Posts
    Rep Power
    363

    Re: A Printer Script

    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 ?

  15. #15
    apeo's Avatar
    Join Date
    Sep 2005
    Location
    Lost
    Posts
    1,612
    Thank Post
    95
    Thanked 115 Times in 111 Posts
    Rep Power
    41

    Re: A Printer Script

    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.

SHARE:
+ Post New Thread
Page 1 of 11 12345 ... LastLast

Similar Threads

  1. logon script for printer
    By ozzy in forum Scripts
    Replies: 6
    Last Post: 22nd November 2007, 03:03 PM
  2. Printer Script
    By faza in forum Scripts
    Replies: 9
    Last Post: 14th September 2007, 08:30 AM
  3. Logon script & Printer script question.
    By Galway in forum Windows
    Replies: 3
    Last Post: 29th August 2007, 11:00 AM
  4. Add printer script not workling
    By mark in forum Windows
    Replies: 6
    Last Post: 15th September 2005, 10:07 AM
  5. Script to delete printer
    By tosca925 in forum Scripts
    Replies: 2
    Last Post: 31st August 2005, 07:45 PM

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
  •