Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Change only the servername of any currently installed printer?

Status
Not open for further replies.
Feb 11, 2005
153
0
0
US
I have 70+ printers that were moved from server X to server Y.

E.G.

\\X\1 now is \\Y\1
\\X\2 now is \\Y\2
\\X\3 now is \\Y\3

and so fourth.

Is there any way to switch any drive mapping easily and keep the one that was the old default still the default one.

E.G. Machine 1 has has printers 1 and 2 loaded from \\X but printer 2 is default. When I map \\Y I want 2 to stay default.

Most everything I have found online is about login scripts or something I want a one time only script to just push everyone over as I can't do anything via login script.
 
Sorry, I haven't got time to put a whole script togther, but hopefully you can use these elements as a starting point.

Code:
strComputer = "."

Set objWMIService = GetObject ("winmgmts:\\" & strComputer & "\root\cimv2")
Set colPrinters = objWMIService.ExecQuery ("Select * From Win32_Printer")

For Each objPrinter in colPrinters
    Wscript.Echo objPrinter.ServerName 
    Wscript.Echo objPrinter.ShareName
    Wscript.Echo objPrinter.Default
Next


This code will list the server and share names for each printer. Am IF statement could sort out the printers connected to your old server. You could use the RemovePrinterConnection and AddPrinterConnection methods to remove the old printer and add a connection to the same on the new server.

The code also shows how to tell which printer is the default, so you should be able to use the SetDefaultPrinter method to reset that.

Again, sorry I could be of more help but I'm a bit pushed for time at the mo.
 
i offered the functionality through a logon script
offered admins ability to deltaPrinterServer=\\oldserver;\\newserver

all alogrithum_isadancer did was to enumerate current printers and any that matched the \\oldserver add to a hash table. then loop through the hash table and remove any printer which is in the hash table, (i hacked the registry directly as i found other methods unreliable in certain circumstances, or shoudl i say slow when there server isnt around..etc), loop through the hash table again and this time replace string on the oldserver with newserver and then map to the \printername of the hash entry...job done.

 
My login script FAQ faq329-5798 shows how to enumerate printers and also provides code for migrating shares to a new server. You could combine the two to remap the printers.

I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
Work SMARTER not HARDER. The Spider's Parlor's Admin Script Pack is a collection of Administrative scripts designed to make IT Administration easier! Save time, get more work done, get the Admin Script Pack.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top