Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# Python2.7
hello,
 
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:- <scriptpath/temp.py>
 
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...
Posted 20-Sep-12 22:43pm
Edited 20-Sep-12 22:56pm
v6
Comments
@AmitGajjar at 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 at 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

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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 script.py >log.txt
 
... then you should get a log file created that you can inspect and hopefully that will have an informative message.
  Permalink  
Comments
sawshalin at 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\TemperaturexmlExtractor.py C:\Program Files (x86)\Hewlett-Packard\sched\
 
i think this is the reason. space between "Program Files (x86)"
give me a solution
BobJanova at 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 at 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)

  Print Answers RSS
0 OriginalGriff 350
1 Jochen Arndt 150
2 Richard MacCutchan 135
3 Andreas Gieriet 100
4 DamithSL 95
0 OriginalGriff 6,045
1 DamithSL 4,601
2 Maciej Los 4,087
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,260


Advertise | Privacy | Mobile
Web04 | 2.8.141220.1 | Last Updated 21 Sep 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100