开发者

Python script started by Task Scheduler can't edit file

开发者 https://www.devze.com 2023-04-05 16:44 出处:网络
I made this python script: # -*- coding: utf-8 -*- from datetime import datetime date = datetime.now() file = open(\'myfile.dat\', \'a+\')

I made this python script:

# -*- coding: utf-8 -*-
from datetime import datetime
date = datetime.now()

file = open('myfile.dat', 'a+')
file.write(str(date)+'\n')

It works fine. But when I schedule 开发者_StackOverflow社区it in the Task Scheduler on Windows Server 2008 the script runs, but it doesn't write to the file. Task Scheduler uses my account to run the script so I don't understand why the results are different.

Any idea what I'm missing?


Have you tried using an absolute path to the file?

I think there is also an option in task scheduler to specify where the script should be run, have you set that to the location of the file you want to write to?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号