Note that there are some explanatory texts on larger screens.

plurals
  1. POpython: win32print.AddPrinter: adding a printer to remote computer
    primarykey
    data
    text
    <p>I am getting the error</p> <pre><code>pywintypes.error: (1801, 'AddPrinter', 'The printer name is invalid.') </code></pre> <p>My intention is to add a network printer to end user computers... heres my def</p> <pre><code>import win32print def AddPrinter(computer, printer): pHandle = win32print.OpenPrinter(printer) #int print "%s = %s"%(printer, pHandle) pInfo = win32print.GetPrinter(pHandle,2) #dict print pInfo win32print.ClosePrinter(pHandle) win32print.AddPrinter(computer, 2, pInfo) if __name__=='__main__': computer = 'remote-pc' printer = r'\\printserver\printer1' AddPrinter(computer, printer) </code></pre> <p>What's the deal here... its got to be a valid printer name, because it successfully pulls the handle and gives me the pInfo dict that it wants... frustrating... I don't want to make any batch files!!</p> <p>Thanks for any help you might have.</p> <p>traceback:</p> <pre><code> \\cheops1\4EPrint1 = &lt;PyPrinterHANDLE:4704604&gt; {'Status': 0, 'UntilTime': 0, 'pDriverName': 'HP Universal Printing PCL 5 (v5.0)', 'cJobs': 0, 'pSepFile': '', 'AveragePPM': 0, 'pPortName': 'IP_10.10.185.5', 'pParameters': '', 'pPrintProcessor': 'hpcpp091', 'Attributes': 8728, 'Priority': 1, 'pPrinterName': '\\\\cheops1\\4EPRINT1', 'DefaultPriority': 0, 'StartTime': 0, 'pDatatype': 'RAW', 'pDevMode': &lt;PyDEVMODEA object at 0x01B92958&gt;, 'pLocation': '10.10.185.5', 'pShareName': '4EPRINT1', 'pServerName': '\\\\cheops1', 'pSecurityDescriptor': &lt;PySECURITY_DESCRIPTOR object at 0x01C74560&gt;, 'pComment': 'Rm 4053, 4E Main Desk Laser, Laserjet 4100 MFP, LNWID - 711096'} Traceback (most recent call last): File "D:\workspace\Clinical Applications\EPIC\EPIC_Values.py", line 183, in &lt;module&gt; AddPrinter(computer, printer) File "D:\workspace\Clinical Applications\EPIC\EPIC_Values.py", line 161, in AddPrinter win32print.AddPrinter(computer, 2, pInfo) pywintypes.error: (1801, 'AddPrinter', 'The printer name is invalid.') </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload