Problem with and windows schtasks

Tom Borkin borkintom at
Sun Nov 18 14:48:16 CET 2012

I have this code:


import subprocess['SchTasks /Create /SC ONCE /TN "My Tasks" /TR "C:/Program
Files/Apache Group/Apache2/htdocs/ccc/" /ST 07:50'], shell=True)['SchTasks /Create /SC ONCE /TN "test" /TR ""
/ST 07:50'], shell=True)
With either call, I get this error:
C:\Program Files\Apache Group\Apache2\htdocs\ccc>
The system cannot find the path specified.

If I remove the ", shell=True" I get this:
C:\Program Files\Apache Group\Apache2\htdocs\ccc>
 C:\Program Files\Apache Group\Apache2\htdocs\ccc\,
line 4, in <module>['SchTasks /Create /SC ONCE /TN "test" /TR ""
/ST 07:50'])
 File "C:\Python27\lib\", line 493, in call
  return Popen(*popenargs, **kwargs).wait()
 File "C:\Python27\lib\", line 679, in __init__ errread,
 File "C:\Python27\lib\", line 896, in _execute_child
WindowsError: [Error 2] The system cannot find the file specified
The file exists in said directory. I can execute it from the cmd prompt.

So I tried this:
pgm = "SchTasks"
args = ['/Create /SC ONCE /TN "test" /TR "" /ST 07:50']
#args = ['/Create', '/SC ONCE', '/TN "test"', '/TR ""', '/ST
cmd = [pgm]
subprocess.Popen(cmd, stdout=subprocess.PIPE).communicate()[0]
but got this error:
ERROR: Invalid argument/option - <<the above argument>>

If I use the other args list I get this error:
ERROR: Invalid argument/option - '/SC ONCE'
so apparently it liked the first argument.

Please advise.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the Python-list mailing list