简体   繁体   English

Windows 任务计划程序无法运行 Python 脚本,错误值:2147944320

[英]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.

相关问题 Python 脚本 Windows 任务调度程序 - Python Script Windows Task Scheduler 在 python 中运行复制文件脚本 27 在 Windows 任务计划程序中获取路径错误 errno22 - run copy file script in python 27 get path error errno22 in Windows Task Scheduler 无法安排 python 脚本通过 Windows 任务计划程序运行 - Cannot schedule a python script to run through Windows Task Scheduler Python 脚本未在 Windows 任务计划程序中运行 - Python script not running in Windows Task Scheduler Windows Task Scheduler终止python脚本,操作码2 - Windows task scheduler terminates python script, opcode 2 Windows 任务计划程序,python 脚本,代码 2147942401 - Windows Task Scheduler, python script, code 2147942401 为什么Windows 10 Task Scheduler执行我的Python脚本时会产生不同的运行 - Why does my Python script run differently when executed by Windows 10 Task Scheduler 在 Windows 任务计划程序上运行 python 脚本时如何修复“上次运行结果 (0x2331)”? - How to fix "last run result (0x2331)" when running a python script on Windows Task Scheduler? 从 Edge 下载文件时,如何在 Windows 任务计划程序中运行 Python 脚本? - How to run a Python script in Windows Task Scheduler when a file is downloaded from Edge? 使用Windows Scheduler通过输入运行python脚本 - Using windows scheduler to run python script with inputs
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM