Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python - Task Scheduler 0x1

Having a frustrating time with scheduling a Python script (C:\Python27\test.py), which has the following code:

import xlrd
import csv
with xlrd.open_workbook('Z:/somefile.xls') as wb:
        sh = wb.sheet_by_index(3)
        with open('Z:/somefile.csv', 'wb') as f:
                c = csv.writer(f)
                for r in range(sh.nrows):
                    c.writerow(sh.row_values(r))

This script is supposed to take worksheet 3 in "somefile.xls" and save it into it's own .csv file. When I run it manually from the Python Shell, it works as intended.

Z:\ is a mapped drive located on an entirely different server.

When I try to run from the Task Scheduler, I keep getting the 0x1 result code. I have the Task set up as the following:

  • Run whether user is logged on or not - Do Not Store Password
  • Run with highest privileges
  • Program/script: python.exe
  • Add arguments (optional): "test.py"
  • Start in (optional): C:\Python27

I've read quite a few posts, all with different suggestions, none of which worked.

Anyone else run into this situation before?

Jeff

like image 666
JBG1983 Avatar asked Apr 02 '14 18:04

JBG1983


People also ask

What is 0x1 in Task Scheduler?

The Task Scheduler (0x1) Error is caused because of a system path issue, your task does not run successfully because it can not find a file to run.

How do I enable history in Task Scheduler?

Open Task Scheduler. In the left pane, right click Task Scheduler (Local), then click Enable All Task History.

What does return code 2147942401 mean?

It may be due to a mistake in your Batch file or while scheduling a task. A scheduled task will only run when the user who created and scheduled the task is logged on. However, you can change it to run when the user is not logged on by special privilege, Log on as a batch job .


1 Answers

I ran into this a few weeks ago, Task Scheduler can be a real pain!

For whatever reason, I have never been able to get a script to run when the "Run whether user is logged on or not" option is selected. I spent something like 10 hours on the phone with my IT department trying to figure it out. It can't be done. Un-checking that option should then allow your script to run.

like image 141
wnnmaw Avatar answered Sep 25 '22 20:09

wnnmaw