批文件故障排除

时间:2016-04-29 13:55:16

标签: batch-file

对以下批处理文件进行故障排除的任何建议。 我确实添加了显示消息,我确实看到了第一条和第二条消息 在第二条消息之后没有任何反应 - 没有错误消息,不再显示批处理文件中的消息。 我验证了目标服务器上的帐户权限 - 它具有完全控制权。 任何建议将不胜感激。谢谢 !!! 这是代码:

start "" /wait cmd /c "echo In Rename Script & echo(&pause"
:: Create the new filename
set tdtd=none
set ttrn=none
set hour=none

:: get the date and time and then into single variable
for /F "tokens=2-4 delims=/ " %%i in ('date /t') do set tdtd=%%k%%i%%j
for /F "tokens=5-8 delims=:. " %%i in ('echo.^| time ^| find "current" ') do set ttrn=%%i%%j

:: get hour If it is less than 10 left pad the hour with a zero
for /F "tokens=5-8 delims=:. " %%h in ('echo.^| time ^| find "current" ') do set hour=%%h

start "" /wait cmd /c "echo ABC & echo(&pause"

if %hour% LSS 10 
     (set tufn=\\outgoing\0245_BMS_%tdtd%0%ttrn%.csv) 
else (set tufn=\\outgoing\0245_BMS_%tdtd%%ttrn%.csv)

start "" /wait cmd /c "echo XYZ & echo(&pause"
copy /Y "\\FileName.csv" %tufn%
start "" /wait cmd /c "echo 123 & echo(&pause"
:END

1 个答案:

答案 0 :(得分:0)

这里你去...我已经修改了一点逻辑以简化它,特别是lss 10部分。并纠正了一些语法错误。

:: Create the new filename
set tdtd=none
set ttrn=none
set hour=none
set tufn=none

:: get the date and time and then into single variable
for /F "tokens=2-4 delims=/ " %%i in ('date /t') do set tdtd=%%k%%i%%j
for /F "tokens=5-8 delims=:. " %%i in ('echo.^| time ^| find "current" ') do set ttrn=%%i%%j

:: get hour If it is less than 10 left pad the hour with a zero
for /F "tokens=5-8 delims=:. " %%h in ('echo.^| time ^| find "current" ') do set hour=%%h

if (%hour% LSS 10) set ttrn=0%ttrn%
set tufn=\\outgoing\0245_BMS_%tdtd%%ttrn%.csv

copy /Y "\FileName.csv" %tufn%

set tdtd=
set ttrn=
set hour=
set tufn=
:END