简体   繁体   English

powershell脚本可在run.exe中运行,但不能作为计划任务运行

[英]powershell script works in run.exe but doesn't work as scheduled task

I scheduled this task below and when I click run in Task Scheduler it doesn't throw any errors but the script doesn't execute: Program: 我在下面计划了此任务,当我单击“任务计划程序”中的“运行”时,它不会引发任何错误,但脚本不会执行:程序:

C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -Command "& S:\Scripts\Download-USPTO-Forms.ps1 -destinationFolder 'S:\Scripts\USPTO Forms'"

When I open Run.exe and run this cmd then the Powershell window opens and the script executes: 当我打开Run.exe并运行此cmd时,将打开Powershell窗口并执行脚本:

C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -Command "& S:\Scripts\Download-USPTO-Forms.ps1 -destinationFolder 'S:\Scripts\USPTO Forms'"

Why is that? 这是为什么? Any ideas? 有任何想法吗? The task seems to be scheduled correctly. 该任务似乎已正确安排。

Why are you using the call operator? 您为什么使用呼叫接线员?

powershell -File "S:\Scripts\Download-USPTO-Forms.ps1" -destinationFolder "S:\Scripts\USPTO Forms"

Furthermore, ensure the task has properly mapped drives and permissions. 此外,确保任务已正确映射驱动器和权限。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM