0

因此,我尝试以编程方式添加打印机,但出现 0x00000709 错误。

什么可能导致这种情况?我怀疑我的代码中的某些内容可能有点不对劲:

import subprocess
def printerSetup(printer):
    subprocess.call(r'Cscript c:/windows/System32/Printing_Admin_Scripts/en-US/Prnport.vbs -a -r "' + printer + '.print.mediag.com" -h "' + printer + '.print.mediag.com" -o raw')
    if printer == 'jupiter':
        subprocess.call(r'rundll32 printui.dll, PrintUIEntry /if /b "' + str.title(printer) + '" /u /y /f w:\printers\\toshibae3511\eng\est_c2.inf /r "' + printer + '.print.mediag.com" /m "TOSHIBA e-STUDIO Color PS3"')
    elif printer == 'saturn' or printer == 'neptune':
        subprocess.call(r'rundll32 printui.dll, PrintUIEntry /if /b "' + str.title(printer) + '" /u /f w:\printers\\toshibae3511\eng\est_c2.inf /r "' + printer + '.print.mediag.com" /m "TOSHIBA e-STUDIO Color PS3"')  
    elif printer == 'mercury':
        subprocess.call(r'rundll32 printui.dll, PrintUIEntry /if /b "' + str.title(printer) + '" /u /f w:\printers\dell1720\drivers\print\dell1720\DKABJ740.inf /r "' + printer + '.print.mediag.com" /m "Dell Laser Printer 1720dn"')
    elif printer == 'sonic' or printer == 'pangea':
         subprocess.call(r'rundll32 printui.dll, PrintUIEntry /if /b "' + str.title(printer) + '" /u /f w:\printers\HPUniversalPS_x64\hpcu112v.inf /r "' + printer + '.print.mediag.com" /m "HP Universal Printing PS"')

printerList = ["neptune", "saturn", "mercury", "jupiter", "sonic", "pangea"]

for x in printerList:

    printerSetup(x)

现在,这些打印机中的每一个都肯定已添加到网络中,并且我正在调用 Windows 的打印脚本 - 它可能与我的列表有关吗?

4

1 回答 1

0

你必须传递一个列表:

subprocess.call(['Cscript', r'c:/windows/System32/Printing_Admin_Scripts/en-US/Prnport.vbs', '-a', ...])

还要检查报价...

看看http://docs.python.org/library/subprocess.html?highlight=subprocess#subprocess.check_call

于 2012-05-14T15:22:38.500 回答