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.
  • Posts

    • That explains my recent issues with classic Outlook. I can see the FORMS2 folder has resolved the issue on my system.
    • Brave 1.79.126 by Razvan Serea Brave Browser is a lightning-fast, secure web browser that stands out from the competition with its focus on privacy, security, and speed. With features like HTTPS Everywhere and built-in tracker blocking, Brave keeps your online activities safe from prying eyes. Brave is one of the safest browsers on the market today. It blocks third-party data storage. It protects from browser fingerprinting. And it does all this by default. Speed - Brave is built on Chromium, the same technology that powers Google Chrome, and is optimized for speed, providing a fast and responsive browsing experience. Brave Browser also features Brave Rewards, a system that rewards users with Basic Attention Tokens (BAT) for viewing opt-in ads. This innovative system provides an alternative revenue model for content creators and a way to support the Brave community. Brave 1.79.126 changelog: Fixed crash when clicking on shields panel in certain cases. Fixed crash on navigation when a Google sign-in request has been triggered. (#46769) Fixed crash when Leo generates empty list when clicking on “Suggest questions” while using BYOM (Bring Your Own Model). (#46843) Fixed issue importing from Trezor wallet when Trezor Connect is outdated. (#46660) Upgraded Chromium to 137.0.7151.119. (#46911) Download: Brave Browser 64-bit | 1.2 MB (Freeware) Download: Brave Browser 32-bit View: Brave Homepage | Offline Installers | Screenshot Get alerted to all of our Software updates on Twitter at @NeowinSoftware
    • LeafView 3.6.5 by Razvan Serea LeafView is a fast, open-source image viewer built with Electron. It offers a sleek, minimal UI for fast and efficient image browsing. Supporting various formats, LeafView ensures a smooth viewing experience with essential features like zoom, rotation, and slideshow mode. Designed for simplicity and performance, it utilizes hardware acceleration for smooth rendering and supports touch gestures for seamless navigation. LeafView key features: Lightweight & Open-Source – Minimal resource usage with a clean, efficient design Electron-Based – Cross-platform compatibility with modern UI Multiple Image Format Support – Opens JPG, PNG, GIF, BMP, and more Smooth Rendering – Hardware acceleration for fast performance Essential Image Controls – Zoom, rotate, and slideshow mode Touch Gesture Support – Seamless navigation on compatible devices Minimal UI – Focused on simplicity and ease of use LeafView 3.6.5 changelog: Update electron to v36.5.0 Download: LeafView 3.6.5 | Portable | ~100.0 MB (Open Source) View: LeafView Website | Other operating systems | Screenshot Get alerted to all of our Software updates on Twitter at @NeowinSoftware
    • Which is why I continue to use Open Shell for my start menu. your best course of action is to install a third-party Start menu
  • Recent Achievements

    • First Post
      Fuzz_c earned a badge
      First Post
    • First Post
      TIGOSS earned a badge
      First Post
    • Week One Done
      slackerzz earned a badge
      Week One Done
    • Week One Done
      vivetool earned a badge
      Week One Done
    • Reacting Well
      pnajbar earned a badge
      Reacting Well
  • Popular Contributors

    1. 1
      +primortal
      700
    2. 2
      ATLien_0
      280
    3. 3
      Michael Scrip
      208
    4. 4
      +FloatingFatMan
      196
    5. 5
      Steven P.
      130
  • Tell a friend

    Love Neowin? Tell a friend!