Script/Batch to map Network printer


Recommended Posts

I'm trying to set up a local logon script to map a network printer (has a UNC of \\server1\Lexmark).

The problem is that due to the configuration of the network (out of my hands), the printer requires a username and password (for the sake of examples, let's assume the username is "Name" and the password is "Pass") every logon.

The simple workaround is to browse to the UNC address of the printer every login, and enter the username and password into the prompt. This is a massive inconvenience however.

I'm hoping that via a logon script, the printer will be remapped automatically every logon.

I am aware of the Net Use and the other common methods for mapping a network printer, however I do not know any that allow the username and password to be passed via the logon script/batch.

(Security of the username and password is not an issue. The account used for this is a limited account with pretty much only local printer access).

Link to comment
https://www.neowin.net/forum/topic/392794-scriptbatch-to-map-network-printer/
Share on other sites

you can try modifying this script.. i took from computerperformance.co.uk

it was a script to map a network drive, i edited for a printer.. its just guess work

no clue if it will work for you...Edit user/pass variable and let me know!

  Quote
Option Explicit

Dim objNetwork

Dim? strUser, strPassword, strUNCPrinter

' Values of variables set

strUNCPrinter = "\\server1\Lexmark"

strUser = "guytom"

strPassword = "?@ssw0rd1"

Set objNetwork = WScript.CreateObject("WScript.Network")

objNetwork.AddWindowsPrinterConnection strUNCPrinter, strUser, strPassword

WScript.Echo "Script finish, Check printer"

WScript.Quit

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.