Command-line does work when scheduled

Jay Loden python at jayloden.com
Sun Sep 30 23:42:51 EDT 2007


I sometimes see issues like this at work because certain processes, including scheduled tasks if I remember right, can run as Local System user instead of as your user account. That tends to be a real pain for Python or Perl scripts because that means that they don't have the associations configured properly. You can play around a bit as Local System to find out, using an old trick: 

open a command prompt and type the following:

  at nn:nn /interactive cmd

where nn:nn is one minute from the current time (24 hour clock, so 11:30 pm would be 24:30). This will launch a cmd prompt on your desktop, but running as Local System instead of as yourself. From there you can see what your script does when you run it as the System user, and see what assoc .py says etc. 

If you still can't figure it out, the only other things I can think of would be to wrap it in a .bat file and try using that for your scheduled task, or using py2exe to compile your script to an exe which should eliminate the whole file association/PATH issue altogether ;)

Hope that helps,

-Jay

Gabriel Genellina wrote:
> No more ideas... I think the scheduler just executes the command line, and  
> if it works in a console, should work in the scheduler too... Unless you  
> execute the job under another user, who has a different association for  
> .py files, that's the only reason I can think of.



More information about the Python-list mailing list