调用 Python 脚本的 Powershell 脚本自动化不起作用(通过任务计划程序)
我试图在装有 Windows 的 PC 上创建一堆自动化程序,在尝试使用 Windows 任务计划程序自动化 Powershell 脚本时遇到了一些障碍。
现在,我已经设法设置一个任务计划程序来执行实际的脚本,但是尽管当我手动启动它时整个脚本按预期工作,但通过任务计划程序调用时它无法正常工作。
Powershell脚本非常简单,它的目的是调用某个Python脚本。我还创建了一个日志记录用于测试目的。
python dataset_creator.py --to_import yes --to_export yes
Start-Transcript -Path "<path>\transcript0.txt"
手动调用时,Python 脚本可以工作,但通过任务计划程序,唯一的工作部分是创建脚本(因此 - 没有 Python 脚本运行)。任务计划程序通知我自己任务已正确执行。这就是我设置操作的方式:
Program: %SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe
Arguments: -NoProfile -NoLogo -NonInteractive -ExecutionPolicy Bypass -File "C:\<path>\powershell_script.ps1"
目前,我已将其设置在系统帐户上,我已尝试将其设置在我的用户管理帐户上,但效果不佳。
您能建议潜在的问题吗?我浏览了几篇文章,但没有任何效果。我还尝试跳过 Powershell 部分(又名 - 设置仅依赖于 Python 任务的任务),但到目前为止还不起作用,而且我最初还想将多个 Python 脚本调用插入到单个 Powershell 文件中。
我也愿意接受一些 Windows 任务计划程序替代建议。
I am trying to create a bunch of automations on my PC with Windows, and I encountered some obstacles while trying to automate a Powershell script with Windows Task Scheduler.
Right now, I have managed to set up a Task Scheduler to perform an actual script, but despite the whole script working as intended when I start it manually, it doesn't work right while invoked via task scheduler.
The Powershell script is very simple, it is meant to invoke a certain Python script. I also created a log transcript for testing purposes.
python dataset_creator.py --to_import yes --to_export yes
Start-Transcript -Path "<path>\transcript0.txt"
While invoked manually, the Python script works, but via Task Scheduler, the only working part is a transcript creation (ergo - no Python script is running). The Task Scheduler informs me itself that the task executed properly. This is how I set up the action:
Program: %SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe
Arguments: -NoProfile -NoLogo -NonInteractive -ExecutionPolicy Bypass -File "C:\<path>\powershell_script.ps1"
As for now, I have set it on a SYSTEM account, I have tried to set it on my user admin account, but it doesn't work as well.
Could you suggest the potential issues? I scrolled through several articles and nothing works. I also tried to skip the Powershell part (aka - set up the task relying only on a Python task), but it didn't work so far, and I also initially wanted to insert a number of Python scripts invokations into a single Powershell file.
I am also open to some Windows Task Scheduler alternatives suggestions.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论