Unable to add network printer using python
Question: I am very new to python and trying to execute printer installation using
python but it doesn't work. If I execute the same using cmd, it works.

    
    
    import os
    os.system("rundll32 printui.dll PrintUIEntry /in /n \\print-kunnu.com\FollowYou")
    

When I run this, it shows output as `0` which indicates output is success. But
it doesn't add the printer.

If I run this in command prompt:

    
    
    rundll32 printui.dll PrintUIEntry /in /n \\print-kunnu.com\FollowYou  
    

it adds the printer.

Could you please let me know what wrong I am doing ?


Answer: This could be a path issue. You could try to provide absolute path for
rundll32 and the dll. Another possible issue would be the parsing. If you were
running on Linux, I would suggest using shlex but on Windows, I am not sure
how it behaves. Try to catch the exception via: import os try:
os.system("rundll32 printui.dll PrintUIEntry /in /n \print-
kunnu.com\FollowYou") except: exc_type, exc_obj, exc_tb = sys.exc_info() print
"Error: " + str(exc_type)

