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

WSH Mapping of Printers - HELP!

Status
Not open for further replies.

Bannon

Programmer
Jun 10, 2001
23
0
0
US
Hi. I want to be able to map some printer and drive shares in the users logon script (WSH). The code below has no problem with the drive, however an error is returned when the printer is mapped. It says that the printer name is invalid.

If I copy the "\\dcs-hermes\HP LaserJet 2100" part on its own and stick it in any computers command prompt I get the que. I have triple-double checked the share name and have tried to make it 16bit compatible by changing the name to LJ2100 with no luck.

It is connected to the domain controller running Win2k and AD on lpt1.

Code:
set WshNetwork = CreateObject ("Wscript.Network")

WshNetwork.AddWindowsPrinterConnection "lpt2", "\\dcs-hermes\HP LaserJet 2100"

WshNetwork.MapNetworkDrive "n:", "\\dcs-hermes\Network Filesystem"

WScript.Echo "You are now connected to the network printers and Drives"

Any help would be appreciated.
 
Hi,
to map you printer try this:
WshNetwork.AddWindowsPrinterConnection "\\dcs-hermes\HP LaserJet 2100"
If you need the Printer in an DOS-Environment then you can map the printer to an lpt-Port - the Syntax for that:
WshNetwork.AddPrinterConnection "lpt2","\\dcs-hermes\HP LaserJet 2100"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top