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!

Adding printer 1

Status
Not open for further replies.

mot98

MIS
Jan 25, 2002
647
CA
Hi All,

I have been told that I can add a network printer during the logon script. I believe the correct syntax is:

' vb script to add printers via login script
Set WshNetwork = CreateObject("WScript.Network")
PrinterPath = "\\vtserver2b\HP4MEngr"
PrinterDriver = "HP LaserJet 4M"
WshNetwork.AddWindowsPrinterConnection PrinterPath, PrinterDriver


Do I put this directly in my logon script? Or do I have to create it as a VB Script and then call it from the batch file.

Thanks,
mot98
[pc]

"Every day I learn something new, and forget 10 things I learned long ago!"
 
you need to put it in a vbs file and call it from the login script,

use

Wscript nameoffile.vbs

within your login script Regards
Steve Friday
 
Thanks Steve,

I have done this and the program seems to work great. However when it installs the printer, it is doing so with the local port "LPT1". How can I get it to install with a network port?

Thanks,

mot98
[pc]

"Every day I learn something new, and forget 10 things I learned long ago!"
 
Set WshNetwork = WScript.CreateObject("WScript.Network")
PrinterPath = "\\printserver\HP4050-1"
WshNetwork.AddWindowsPrinterConnection PrinterPath
WshNetwork.SetDefaultPrinter PrinterPath

I used ythe above code and created the printer on the workstation and et it as default and used a network port not a LPT

Is there maybe somewhere else in your login script that maps it to lpt1?

 
Hi spazman,

For some reason this is still not working for me. It is still creating it to the LPT1 port. I have edited the logon script to only have the VB Script in it, so nothing should be effecting it.

I am trying to run this on a win95 client with WSH 5.5 installed.

Is there something else I am missing here?

Thanks,
mot98
[pc]

"Every day I learn something new, and forget 10 things I learned long ago!"
 
I did it on a w2k PRo with 5.6 scripting, try updating the script engine, just a thought.

let me know.
 
I installed 5.6 scripting and it is still not working. I tried it on one of my w2k pro machines too and it worked.

Must be something wrong with win95.

Has anyone seen this before and know a fix?

Thanks,
mot98
[pc]

"Every day I learn something new, and forget 10 things I learned long ago!"
 
AddWindowsPrinterConnection in Windows 9x will default to LPT1


AddWindowsPrinterConnection(printerpath, drivername, port) is for 95

and AddWindowsPrinterConnection(printerpath) is for 2K

taken from VBSCRIPT in a Nutshell




Regards
Steve Friday
 
Thanks Steve,

It worked great. mot98
[pc]

"Every day I learn something new, and forget 10 things I learned long ago!"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top