简体   繁体   中英

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:

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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