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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Mapping a Network Printer - Logon Script

Status
Not open for further replies.

Momozone

IS-IT--Management
Dec 2, 2004
103
IE
OS: Windows Server 2003
Active Directory
Printer Installed and Shared

In my login script I have the following:

NET USE \\IPADDRESS\PRINTER

However the printer does not appear as a printer that can be used on the PC after this command.

I have tried to enter it manually on the PC and it says "Operation Successful" however the same the printer does not appear in the printers pane in control panel. Has anyone every experienced this issue?

I can confirm it is not a permissions issue as I can add the printer manually using "Add Printer".

Regards,

MOMOZONE

MoMoZoNe
 
I am not using VBScript. I am using a batch script. The operation completes but printer does not appear. Thanks for your reply anyway.


MoMoZoNe
 
VB script works more reliably try the script below, just change the \servername\printername part.

Code:
Set WSHNetwork = CreateObject("WScript.Network")

WSHNetwork.AddWindowsPrinterConnection "\\servername\printername"

set WSHNetwork = Nothing

'Quit the Script
wscript.quit
 
I should add that NET USE does not add the printer to Control Panel - Printers.
 
But the printer should be available to print to?

As it is currently not.




MoMoZoNe
 
Its been a while but wouldn't you need to associate a port e.g NET USE LPT1: \\[Computer Name]\Printer /PERSISTENT:YES and then get the program to print to the port.

Is this a DOS app?
 
I can add a printer to LPT1 with this command
Code:
NET USE LPT1: \\server\printer

i can then print to it from the command line with print
Code:
test.txt /d:lpt1
but i can't print to it from a windows app.


I'd suggest using the VB script if you want windows apps to use it.
 
If you prefer to stick with NT Shell/batch commands, you can call a built-in VBS script to add the printers.

%windir%\system32\cscript.exe %windir%\system32\prnmngr.vbs -ac -p "\\PRINTSERVER\PRINTSHARE"

 
Another valid way of doing this in a batch file is to use "rundll32 printui.dll,PrintUIEntry /in /n \\server\printer"

This will also install the drivers, if they aren't already there.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top