Scripts Thread, Discover Default Printer & Change Default Based On Answer in Coding and Web Development; We have upgraded from an old DC to a new DC and I am trying to map all users to ...
-
13th April 2011, 06:54 AM #1
- Rep Power
- 0
Discover Default Printer & Change Default Based On Answer
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!
-
-
IDG Tech News
SHARE: 
Similar Threads
-
By philjones2000 in forum MIS Systems
Replies: 6
Last Post: 15th September 2010, 03:16 PM
-
By chrisjako in forum Windows Server 2000/2003
Replies: 0
Last Post: 25th February 2010, 10:11 AM
-
By darknova in forum Windows Server 2008
Replies: 1
Last Post: 13th March 2008, 03:57 PM
-
By martyn in forum Scripts
Replies: 13
Last Post: 20th February 2008, 04:29 PM
-
By speckytecky in forum Wireless Networks
Replies: 1
Last Post: 31st May 2006, 06:44 PM
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules