• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 693
  • Last Modified:

VBScript to map network printers from XP home edition laptop

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.  

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

For Each queue In PrinterShares
      PrinterPath = "\\printserver\" & queue.name
      WshNetwork.AddWindowsPrinterConnection PrinterPath
Next
=============================================
0
CRIIT
Asked:
CRIIT
  • 3
  • 2
3 Solutions
 
rockiroadsCommented:
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

http://wsh2.freeweb.hu/ch11c.html
0
 
CRIITAuthor Commented:
I get "Error: Code 70 Permission denied"
0
 
rockiroadsCommented:
some work arounds listed here, try them http://www.visualbasicscript.com/m_1263/tm.htm
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
ZabagaRCommented:
0
 
CRIITAuthor Commented:
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.
0
 
rockiroadsCommented:
No probs, what a pain though
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now