Link to home
Start Free TrialLog in
Avatar of CRIIT
CRIITFlag for Afghanistan

asked on

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
=============================================
SOLUTION
Avatar of rockiroads
rockiroads
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of CRIIT

ASKER

I get "Error: Code 70 Permission denied"
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of CRIIT

ASKER

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.
No probs, what a pain though