I am trying to use Windows Task scheduler to run a Powershell script

The problem is that when I use the following:-

-noexit -NoProfile -ExecutionPolicy Bypass -command "& ' C:\Program File(x86)\WinSCP\WinSCP" /ini-nul/script=C:\Users\Glen\Desktop\WinSCP\Downloadscript.txt"

I get the following error message;

**The string is missing the terminator:'.

  • CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
  • FullyQualifiedErrorID : TerminatorExpectedAtEndOfString**

It runs OK in Powershell both ise and V1.0 but will not work using Task Scheduler

Using Windows 10

1 Answer

You have a " instead of ' in your command line. Change it to this:

-noexit -NoProfile -ExecutionPolicy Bypass -command "& 'C:\Program File(x86)\WinSCP\WinSCP' /ini-nul/script=C:\Users\Glen\Desktop\WinSCP\Downloadscript.txt"

The winscp parameters seem to be incorrect as well. I assume

/ini-nul/script=...

should be

/ini=nul /script=...
3

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like