Export (0) Print
Expand All

RenamePrinter method of the Win32_Printer class

The RenamePrinter WMI class method renames a printer.

This topic uses Managed Object Format (MOF) syntax. For more information about using this method, see Calling a Method.

Syntax


uint32 RenamePrinter(
  [in]  string NewPrinterName
);

Parameters

NewPrinterName [in]

New printer name.

Return value

Return codeDescription
0

Success

5

Access Denied

1801

Invalid Printer Name

 

Examples

The following VBScript example renames both a printer and its printer share name.


strComputer = "." 
Set objWMIService = GetObject("winmgmts:" _ 
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") 
 
Set colPrinters =  objWMIService.ExecQuery _ 
    ("Select * from Win32_Printer Where DeviceID = 'HP LaserJet 4Si M'") 
 
For Each objPrinter in colPrinters 
    objPrinter.RenamePrinter("ArtDepartmentPrinter") 
Next 
 
Set colPrinters = objWMIService.ExecQuery _ 
    ("Select * From Win32_Printer Where DeviceID = 'ArtDepartmentPrinter' ") 
 
For Each objPrinter in colPrinters 
    objPrinter.ShareName = "ArtDepartmentPrinter" 
    objPrinter.Put_ 
Next 

Requirements

Minimum supported client

Windows Vista

Minimum supported server

Windows Server 2003

Namespace

\root\CIMV2

MOF

CIMWin32.mof

DLL

CIMWin32.dll

See also

Computer System Hardware Classes
Win32_Printer

 

 

Show:
© 2014 Microsoft