VBScript to map network printers from XP home edition laptop

Posted on 2006-05-16
Last Modified: 2013-11-13
Some users in my network use XP home edition laptop and can't joint to the domain to use network printers.  I would like to write a VBscript to map the network printers for them by double clicking the VBScript file.  I wrote a code as below and it doesn't work.  I think I may need to get credential from the print server.  Does anyone knows how to do that.  

Set WshNetwork = WScript.CreateObject("WScript.Network")
Set PrinterShares = GetObject("WinNT://printserver")
PrinterShares.filter = array("PrintQueue")

For Each queue In PrinterShares
      PrinterPath = "\\printserver\" &
      WshNetwork.AddWindowsPrinterConnection PrinterPath
Question by:CRIIT
    LVL 65

    Assisted Solution

    what error code does it fall over on

    see this code here
    it gives an example with error trapping, use this, to help determine your error

    Author Comment

    I get "Error: Code 70 Permission denied"
    LVL 65

    Accepted Solution

    some work arounds listed here, try them
    LVL 15

    Assisted Solution


    Author Comment

    Thanks, Rockiroads.

    I have to create a hidden share folder on print server first.  Using "MapNetworkDrive" function which accepts username/password arguments to get the authentication.  The I can map the network printers bu using "AddWindowsPrinterConnection" funtion.  I remove the network drive by using "RemoveNetworkDrive" in the end.
    LVL 65

    Expert Comment

    No probs, what a pain though

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    INTRODUCTION We all know how to code. But at times you simply want to insert a common code block into your existing code and amend it as per your requirements. This tool not only saves you time but also saves you the pain of typing it all out aga…
    Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
    In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    794 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now