I have a CMD file that connects to an FTP server to transfer files. When the FTP server is unavailable, an alert email should be sent by a seperate Powershell script. Everything works fine when I run the script form a Command Prompt, when the CMD file is executed by a scheduled task the mail is not sent.
Since there is no problem when the batch file is executed from a command prompt, I guess the problem must be located in the scheduled task-settings, not in the script.
Batch file details:
<code to connect to the FTP server>
if %ERRORLEVEL% neq 0 goto error
echo Upload succeeded, moving local files
<code to move the files from the local drive to the FTP server>
exit /b 0
powershell.exe -ExecutionPolicy Bypass -Command ".\mail.ps1"
exit /b 1
Scheduled task details:
- runs with administrator account
- run whether user is logged on or not
- run with highest priviliges
- Action: Start a program
- Program/script: C:\Windows\System32\cmd.exe
- Add arguments: /c <path to the cmd file>
Any ideas what the limitation of the scheduled task could be?