[英]Windows Task Scheduler unable to run Python Script, error value: 2147944320
I have created a new task, with one action: Start a program.我创建了一个新任务,只需一个操作:启动一个程序。 I followed the instructions from https://www.jcchouinard.com/python-automation-using-task-scheduler/
我按照https://www.jcchouinard.com/python-automation-using-task-scheduler/的说明进行操作
my python script looks like this:我的 python 脚本如下所示:
if __name__ == '__main__':
num = 1
Under general properties, I have 'run whether user is logged on or not' checked, 'run with highest privileges' checked, and myself as the user running the task.在一般属性下,我检查了“无论用户是否登录都运行”,“以最高权限运行”检查,并且我自己作为运行任务的用户。 I am an administrator.
我是管理员。
Action Parameters...动作参数...
Program/script : C:\Users\myuser\AppData\Local\Microsoft\WindowsApps\python.exe (pasted from command where python
)程序/脚本:C:\Users\myuser\AppData\Local\Microsoft\WindowsApps\python.exe(从
where python
命令粘贴)
Add arguments : py_test.py添加 arguments :py_test.py
Start in : C:\Users\myuser\Desktop开始于:C:\Users\myuser\Desktop
I tested from the command line that I can run this command successfully:我从命令行测试我可以成功运行这个命令:
C:\Users\myuser\AppData\Local\Microsoft\WindowsApps\python.exe C:\Users\myuser\Desktop\py_test.py
When I click 'run' from the task scheduler library, I get the error 'The file cannot be accessed by the system.当我从任务计划程序库中单击“运行”时,出现错误“系统无法访问该文件。 (0x80070780)
(0x80070780)
When I go into the history for the task, I see this error:当我 go 进入任务的历史记录时,我看到了这个错误:
Task Scheduler failed to launch action "C:\Users\myuser\AppData\Local\Microsoft\WindowsApps\python.exe" in instance "{6204cea7-bedc-40f9-bc10-ac95b9e02460}" of task "\TestPythonJob".
任务计划程序无法在任务“\TestPythonJob”的实例“{6204cea7-bedc-40f9-bc10-ac95b9e02460}”中启动操作“C:\Users\myuser\AppData\Local\Microsoft\WindowsApps\python.exe”。 Additional Data: Error Value: 2147944320.
附加数据:错误值:2147944320。
I confirmed under the executable file's properties that I and SYSTEM have access to it.我在可执行文件的属性下确认我和 SYSTEM 可以访问它。 I tried researching this error value but could not find anything.
我尝试研究此错误值,但找不到任何东西。 What could be the issue?
可能是什么问题?
Maybe try adding python to your path environment variables.也许尝试将 python 添加到您的路径环境变量中。 Then make a.bat to run it.
然后制作一个.bat 来运行它。 Here's how to use a.bat with task scheduler https://www.python.org/ftp/python/3.9.5/python-3.9.5-amd64.exe .
以下是如何将 a.bat 与任务调度程序https://www.python.org/ftp/python/3.9.5/python-3.9.5-amd64.exe 一起使用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.