批处理文件输出问题

时间:2020-07-19 17:18:17

标签: powershell batch-file

我有一个批处理文件,如果我手动运行,它会生成一个带有单个数字的文本文件。但是,如果我使用Task Scheduler计划它,则会产生“错误”。让我知道我做错了什么。

批处理文件:

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

“错误”输出:

'-' 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)......

0 个答案:

没有答案
相关问题