Click here to Skip to main content
15,937,066 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:

first i'll go step by step

1) i want to schedule python script to run on windows scheduler
couple of week ago i did it, i use bat (.bat) file to do this,
in bat file,
first execute python exe (.exe) then pass path of the python script and argument to the script
eg:- <path of="" python.exe=""> <scriptpath/> <argument>

What this script does is, It's read XML file on same location to get some parameters and do something. In my C# coding i create XML and bat file and format of bat is described as above. Python script, bat file and XML files are in same location,I pass location of XML as argument to the script.

2) I add this bat into windows scheduler programmatically and it's working fine, does what i need

3) Then i creates setup project and install it

4) Now i can run my application, it's create all necessary files in installation folder at execution time (XML and bat), bat file format also correct.

At the scheduler execution time, start cmd(command prompt) and start python interpreter and python interpreter get lost after fraction of second and give some messages.But i cannot check those ...

When i run this through VS 2010 it creates necessary files and add bat file into scheduler, at scheduled time bat file executes successfully.

My question is this,
Why this same project working fine in Visual Studio 2010 and Not as a installed program??? Actually at the schedule time bat file execution...
Updated 20-Sep-12 21:56pm
AmitGajjar 21-Sep-12 3:57am    
Add Logging in your file to get the error message. Also check user have appropriate access rights ? there are authentication section in task scheduler check that.
sawshalin 21-Sep-12 4:01am    
i disable virus guard and run program using administrator privileges.

what's the meaning of "Add Logging in your file to get the error message"

without admin privileges windows task scheduler run other bat files successfully

1 solution

Either the task scheduler is running it as a user which doesn't have the permissions it needs, or it is running it without setting the environment variables that Python needs to execute correctly.

If you have your batch script run

python >log.txt

... then you should get a log file created that you can inspect and hopefully that will have an informative message.
Share this answer
sawshalin 21-Sep-12 10:03am    
environment variables are OK
script also running well,when its in any other location on my computer

here is bat file lines

C:\Python27\python.exe C:\Program Files (x86)\Hewlett-Packard\sched\ C:\Program Files (x86)\Hewlett-Packard\sched\

i think this is the reason. space between "Program Files (x86)"
give me a solution
BobJanova 21-Sep-12 11:19am    
Learn how to use the command line. This command wouldn't run from anywhere. You need to put quotes around command line parameters that have spaces in.
sawshalin 21-Sep-12 11:39am    
Thanks dude..Thatz what i want..Now its working fine..:D

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900