Dear all,

this is my first post to the list, so if I am not sufficiently detailed let me know. Not even sure if this is the best list to send this to as it seems to be an issue with Windows service privileges.

We have been running a package of python scripts as services on a Windows XP machine for several years. These scripts include one that checks a mail server, processes mails and then prints to the attachements to the default printer. This is the only part that does not work, as a service, when migrating the package to Win7/8. The printing script works fine when executing it from the console. An odd thing also is that the script runs smoothly through as a service with not error message, but does not print.

The inital script was in Python 2.4:
--------

print_service.py
---
...
printcmd = "C:/Python24/python.exe C:/Application/printpostdelivery.py"
...
cmd = "%s %s" % (printcmd ,pdfname  )
(stdout, stdin, stderr) = popen2.popen3( cmd )
screen = stdout.read()
err_screen = stderr.read()
...
---

printpostdelivery.py
---
...
win32api.ShellExecute(0, "print", dateiname, None, ".", 0);
...
---
--------

I upgraded to Python 2.7 and changed to lines in print_service.py accordingly:
--------

print_service.py
---
...
printcmd = "C:/Python27/python.exe C:/Application/printpostdelivery.py"
...
cmd = "%s %s" % (printcmd ,pdfname )
p = subprocess.Popen(cmd, shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
(child_stdin,  child_stdout, child_stderr) = (p.stdin, p.stdout, p.stderr)
screen = child_stdout.read()
err_screen = child_stderr.read()
...
---
--------

I played around with the service settings and ran it as administrator, but that did not help...well, only that initially there was an error message when running the service with Python 2.7:
pywintypes.error: (31, 'ShellExecute', 'A device attached to the
system is not functioning.')
But that disappeared when I ran the service as an administrator.
Then it was the same all over again. Script runs through smoothly with no error, but the documents were not printed.

Any suggestions?
Thanks!

All the best

Kristof
--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to