View Single Post
  #1 (permalink)  
Old April 30th, 2004, 01:40 PM
dddane dddane is offline
Registered User
Join Date: Apr 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to dddane
Default Determining what default printer is in VBS/WSH

Determining what default printer is in VBS/WSH
I'm trying to map each user's printers to a new print server with their login script in WSH.

I have the code (below) to successfully do this. However, the ONLY thing missing is setting the default printer. I know that there is a method that DOES set the default printer, but I first need to know what their old default printer was. I haven't been able to find this. I found (in other wrox forums) code in VB that will use API calls to do this--but AFAIK these won't work from WSH.

The code I have (slightly sloppy, I know, but it works) is this:


For i = 0 to oPrinters.Count - 1 Step 2

if Trim(oPrinters.Item(i+1)) = oldPrinter then
'Printer found. Lets add the replacement, if successful delete the old. 

WshNetwork.AddWindowsPrinterConnection newPrinter

If Err 0 OR blnError = True Then
'Printer was NOT added


WshNetwork.RemovePrinterConnection oldPrinter, true, true 
End If 'end if err0

End If 'end if printer matches current


I do this for each printer we have on our network. I don't worry about specifying drivers, as I made a point to use the same driver version on both servers (for anyone copying, this may create an issue if the new print server has a different driver and the user it is being added from does not have local administrative rights). Each user has 5-10 printers that are actually remapped.

Any help on this? Thanks

Reply With Quote