1
I'm trying to run a simple PS1 powershell script from the Task Scheduler. The task's Actions settings are Program: powershell
and Add arguments: -executionpolicy bypass -file C:\Users\Robin\Documents\script.PS1
.
The objective script.PS1 is accessed ok but a line within it (a call to another script: Rscript Z:\rscript.R
) fails with the message:
Fatal error: cannot open file Rscript Z:\rscript.R
'rscript.R': no such file or directory
If I run the same line manually in Powershell it works ok. Moreover the following runs fine as a Run command: powershell -executionpolicy bypass -file C:\Users\Robin\Documents\script.PS1
, which suggests the problem is in Task Scheduler. The task is set to run with highest privileges. I'm stumped.
Very grateful for assistance.
I wonder if its something to do with the 2nd script residing on a networked drive.. – geotheory – 2013-08-08T12:38:45.060
Try creating a batch script to run powershell and call your script, then schedule the batch file. Let me know if it behaves the same way. – Moses – 2013-08-08T12:59:15.477
OK I've tried it using
powershell.exe -file "C:\Users\Robin\Documents\script.ps1
and withRscript Z:\rscript.R
. In both cases the batch file works ok run manually but fails when called from Task Scheduler (same error message). – geotheory – 2013-08-08T13:47:02.230