Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Windows Scripting with Printers - help !!!

Status
Not open for further replies.

rstubbington

Technical User
May 14, 2001
13
GB
I'm trying to create a new Printer on a remote machine via scripting which I have managed to do, but cannot work out how to carry out the 'create new port' part of the addprinter wizard in the script.

I need to add a new local port in the form '\\prntserver\printer', as we add printers on our network as local printers connected to a network port, added as local but pointing to the server.

If anyone can help me to do this I'd be eternally gratefull.
 
If you have local rights on the PC you can use this syntax:

Net Use LPT1: \\ServerName\\ShareNameOfThePrinter /Persistent:yes

do not wrap the lines tho - write the path all on one line.
**Note - there is a space after LPT1:


This will treat the printer as a local one that users cannot delete or change. It will also do another beneficial thing - it will be all user's default server printer if they logon. No more having to re-map network printers everytime somebody new logs on.

:)

Hope this is what you were looking for..
Pbxman
Systems Administrator

Please let Tek-Tips members know their posts were helpful.
 
It's a good idea, but will present a problem where the user needs to print to two different printers - Theirs and there secretaries for instance, as LPT1 will be soley captured to the one printer, when if a new port could be created, you can have multiple printers.

I looked through the Script pages on Microsoft Support and it looks like a VBS script using an Add Port command is the way forward, although I've got no idea about the syntax - all a bit baffling to me - ANY IDEAS ??
 
just use LPT2, LPT3, etc. You can add the printers so they show up in windows as local, but adding the net use command will redirect the LPT number to whichever server you want.

I have LPT1 and LPT2 "local printers" pointing to network printers.
Pbxman
Systems Administrator

Please let Tek-Tips members know their posts were helpful.
 
ok - Worth considering. Still not keen as is much 'messier' than creating a separate port, as will involve trying to get users to tell which printer goes to which port etc, and would mean changing the whole way printers are assigned.

Must be a way to mirror what is done in the add printer wizard in a script.
 
I think you're getting confused as to what i meant - or im confused as to what you want to accomplish. As far as your users go - you can name the printer anything you want to for their ease of use. If anything - it's easier.

Only you know where the printer redirects to - they dont know and dont care as long as it goes to "Big printer by Jon's desk" or whatever you name it.

You can add up to 9 LOCAL LPT ports in windows 2000 - and therefore 9 "Local printers" pointing to network printers as well.

****** For instance - going to start/settings/printers - I see "Claims-HP4050" (our claims department's network printer). It's mapped to LPT1 which i've redirected to \\printserver\Claims-HP4050.

That is a local printer that cannot be changed, and i could also rename it if i wanted to.********

Adding a print port on a remote print server is not a native ability in Windows 2000 - but im sure there are 3rd party utils to do it. That is much more difficult, and definitely not recommended.

Here's a link if you want to try anyway..

You may want to re-evaluate your print functions if you anticipate doing this often.

Does this clear anything up, or do you still want some different result? Sorry for any confusion.
Pbxman
Systems Administrator

Please let Tek-Tips members know their posts were helpful.
 
What I mean is at the moment in Windows 2000, you go to add printer wizard, choose local, and when you get to choose port, you goto create new port, choose local port, and then type \\server\printerhostname, which when OK'd gives the name of the remote printer (\\server\printhostname) as the port, rather than LPTx - to keep using net use I'd have to keep track of how many printers are set up on individual machines, which would be a nightmare, as users are forever moving around the building, primarily with laptops, and changing printers all the time.

I guess ultimately I want to add a new network port to print to on the local machine, without adding as a network printer via the wizard (which for some reason chops off the bottom of the pages of things that print )
 
ok - per your last statement: "..ultimately I want to add a new network port to print to on the local machine, without adding as a network printer via the wizard"

Using the net use command is the only way to do it. You won't have to add a printer through the wizard - it would just dump to LPT1.

You COULD create batch files to map/unmap LPT1 to connect to any printer on the user's desktop.

Example:
Big Printer.bat could contain the path to use a certain printer thgough LPT1, and Small Printer.bat could contain the command to release LPT1, and remap a path to another printer.

In that case way - the paths are recreated whenever the user clicks the batch file, and all documents printed would redirect through LPT1.

Lots of options here - it's up to you to decide what is best for you. :)
Maybe someone else knows of a 3rd party app to use.
Pbxman
Systems Administrator

Please let Tek-Tips members know their posts were helpful.
 
Hmmm, all sounds like creating a lot of extra work for myself when I'm trying to get around having to take control of the user's machine to do anything, or log them off and sign in as Administrator to install new printers.

Cheers for trying though. Can't believe that you can do all the stuff in AddPrinterWizard through the command line, except the add new port bit.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top