

ObjPrinter.ShareName = “ArtDepartmentPrinter”Īs you can see, after we change the printer name we then use this line of code to re-connect to the printer, this time using the new name, ArtDepartmentPrinter: Set colPrinters = objWMIService.ExecQuery _ (“Select * From Win32_Printer Where DeviceID = ‘ArtDepartmentPrinter’ “) Here’s a revised script that changes the printer name and then changes the share name: strComputer = “.” Note that you can change the share name even if the printer isn’t currently being shared. This can be done by changing the printer name, then connecting to the “new” printer and modifying the ShareName property. That’s it because we’re calling a method rather than changing the value of a read/write property we don’t even need to use the Put_ method to save the changes.Īs long as you’re changing the name of the printer you might want to change the share name as well. We set up a For Each loop to loop through the collection, and then use this line of code to rename the printer: objPrinter.RenamePrinter(“ArtDepartmentPrinter”)Īll we do here is call the RenamePrinter method, passing as the sole parameter the new name to be given to the printer.

We then use this line of code to retrieve a collection of all the printers named HP that are installed on that computer: Set colPrinters = objWMIService.ExecQuery _īecause printer names must be unique, the returned collection will consist of, at most, a single item. The script begins by connecting to the WMI service on the local computer. ObjPrinter.RenamePrinter(“ArtDepartmentPrinter”) (“Select * From Win32_Printer Where DeviceID = ‘HP'”) Set colPrinters = objWMIService.ExecQuery _ Set objWMIService = GetObject(“winmgmts:\\” & strComputer & “\root\cimv2”) You want to rename a printer using a script? No problem: strComputer = “.”
#Change printer name shared with airport windows#
That’s because the Win32_Printer class – which was extensively overhauled for Windows XP and Windows Server 2003 – includes a new method named RenamePrinter, a method which definitely lives up to its name. (There might, or might not, be third-party tools that enable you to do this on those older versions of Windows.) If your printer is connected to a computer running Windows XP or Windows Server 2003, however, the news is much better. Well, if your printer is connected to a Windows 2000 or Windows NT 4.0 print server we have bad news for you: you can’t rename a printer using a script, at least not using the technologies included in the operating system. Hey, Scripting Guy! How can I use a script to rename a printer?
