Jump to content

Discover Default Printer & Change Default Based On Answer


Recommended Posts

Posted

We have upgraded from an old DC to a new DC and I am trying to map all users to the new printer shared on the new DC. I would like to find out if the users have the printer on the old DC set as default and if so, change to the new printer. Otherwise just add the new printer and delete the old printer.

 

I am very new to this but this is what I have so far:

 

 

 

strComputer = "."

 

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

 

Set objNetwork = CreateObject("WScript.Network")

objNetwork.AddWindowsPrinterConnection "\\DC02\Printer"

 

Set colInstalledPrinters = objWMIService.ExecQuery _

("Select * from Win32_Printer where Default = 'True'")

 

For Each objPrinter in colInstalledPrinters

If objPrinter.Name = "\\DC01\Printer" Then

objNetwork.SetDefaultPrinter "\\DC02\Printer"

End If

Next

 

Set objNetwork = CreateObject("WScript.Network")

objNetwork.RemovePrinterConnection "\\DC01\Printer"

 

 

 

It will add the new printer and remove the old printer but never discovers the default printer and sets to new printer if it is the old printer. Any ideas? Thanks!

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...