I had almost this exact problem where running a command line app from command line would work, but not when running it as scheduled task.
It turned out the scheduled task is quite sensitive on the fact that parameters must be passed as parameters and not be part of the target .exe.
So if there is anyone other struggling with this kind of problem, make sure you have your command line parameters as parameters (see the picture attached).

Also if you like to make your scheduled task using PowerShell scriptin you can do this like:
$action = New-ScheduledTaskAction -Execute "c:\temp\myApp.exe" -Parameters "testConnection true" -WorkingDirectory "c:\tempFiles\"