语法无效。在谈到命令行内是不可能的cmd
CLI也不是一个批处理脚本:
==>set /a timeto=3600 ::setting default time (1 hour)
Missing operator.
==>set /a timeto=3600
3600
==>
注意%timeTo%*60
超过timeout /T
有效范围-1
到99999
默认3600*60
。
如果您的代码段出现括在括号()
,然后使用Delayed Expansion。
@ECHO ON >NUL
@SETLOCAL EnableExtensions EnableDelayedExpansion
if 1==1 (
rem description for the user to read
echo Insert time in minutes:
rem setting default time (1 hour = 60 minues)
set /a timeTo=60
rem asking user for input (integer)
set /p timeTo=
rem converting minutes to seconds - erroneous
set /a timeTo=%timeTo%*60
rem converting minutes to seconds - right approach
set /a timeTo=!timeTo!*60
rem command based on the inputted value
echo timeout /t !timeTo! /nobreak
)
输出:注意,set /a timeTo=%timeTo%*60
线使Missing operand
误差作为结果错误的set /a timeTo=*60
在分析的时间。
==>D:\bat\SO\32410773.bat
==>if 1 == 1 (
rem description for the user to read
echo Insert time in minutes:
rem setting default time (1 hour = 60 minues)
set /a timeTo=60
rem asking user for input (integer)
set /p timeTo=
rem converting minutes to seconds - erroneous
set /a timeTo=*60
rem converting minutes to seconds - right approach
set /a timeTo=!timeTo!*60
rem command based on the inputted value
echo timeout /t !timeTo! /nobreak
)
Insert time in minutes:
Missing operand.
timeout /t 3600 /nobreak
==>
你不能以这种方式设置的意见。 – npocmaka
我很新的批次。应如何设置评论? (顺便说一下,在我的文件中,我没有这些意见) – jony