I have a batch file which, if I run manually, produces a text file with a single number. However, if I schedule it with Task Scheduler, it produces an "error". Let me know if there is anything obvious that I am doing wrong.
Batch file:
rem Call mysql_start. bat which starts mysql and runs get_rain.bat and sends output to raw_totals.txt
call mysql_start.bat
rem Open raw_totals and remove 'raincounter' header
type C:\CumulusMX\cocorahs_reports\raw_totals.txt | findstr /v raincounter > C:\CumulusMX\cocorahs_reports\raw_totals_no_header.txt
rem Calculate 7a-7a rain and send output to 7-7_rain.txt
setlocal enabledelayedexpansion
set cnt=1
for /f "usebackq" %%i in ("C:\CumulusMX\cocorahs_reports\raw_totals_no_header.txt") do (
set var!cnt!=%%i
set /a cnt+=1
)
(powershell %var1% - %var2%) > C:\CumulusMX\cocorahs_reports\output.txt
powershell exit
rem Delete raw_totals and raw_totals_no_header
del /f C:\CumulusMX\cocorahs_reports\raw_totals.txt
del /f C:\CumulusMX\cocorahs_reports\raw_totals_no_header.txt
"Error" output:
'-' was specified as the argument to -Command but standard input has not been redirected for this process.
PowerShell[.exe] [-PSConsoleFile <file> | -Version <version>]
[-NoLogo] [-NoExit] [-Sta] [-Mta] [-NoProfile] [-NonInteractive]
[-InputFormat {Text | XML}] [-OutputFormat {Text | XML}]
[-WindowStyle <style>] [-EncodedCommand <Base64EncodedCommand>]
[-ConfigurationName <string>]
[-File <filePath> <args>] [-ExecutionPolicy <ExecutionPolicy>]
[-Command { - | <script-block> [-args <arg-array>]
| <string> [<CommandParameters>] } ]
PowerShell[.exe] -Help | -? | /?
(Cutting off for brevity)......