批处理如何让if语句在不执行其后语句时忽略判断其正确性?
如题,当不带第2,3个传入参数时if%3gtr%bp1%(for%%ein(1,1)do(shift/2))等会因语句不完整报错,即便%1不是-cheat代码:[code...
如题,当不带第2,3个传入参数时 if %3 gtr %bp1% (for %%e in (1,1) do (shift /2))等会因语句不完整报错,即便%1不是-cheat
代码:
[code]
@echo off
if "%1"=="" (title it's running)
if "%1"=="-debug" (echo on)
title num
set t=0
set bp1=71
:a
set /a t=%t%+1
echo TEST:%0 %1 %2 %3 %4
if "%1"=="-cheat" (
if "%2"=="" (
shift /1
goto :b)
if "%3"=="" (
for %%e in (1,1) do (shift /1)
goto :b)
if %3 gtr %bp1% (for %%e in (1,1) do (shift /2))
if %2 lss %t% (for %%e in (1,1) do (shift /2))
if %2 equ %t% (
echo %3
for %%e in (1,1) do (shift /2)
pause>nul
goto :a
)
)
:b
set /a n=%random%%%%bp1%
echo %n%
pause>nul
goto :a
[code]
或者有没有其他方法实现所示功能
(win10) 展开
代码:
[code]
@echo off
if "%1"=="" (title it's running)
if "%1"=="-debug" (echo on)
title num
set t=0
set bp1=71
:a
set /a t=%t%+1
echo TEST:%0 %1 %2 %3 %4
if "%1"=="-cheat" (
if "%2"=="" (
shift /1
goto :b)
if "%3"=="" (
for %%e in (1,1) do (shift /1)
goto :b)
if %3 gtr %bp1% (for %%e in (1,1) do (shift /2))
if %2 lss %t% (for %%e in (1,1) do (shift /2))
if %2 equ %t% (
echo %3
for %%e in (1,1) do (shift /2)
pause>nul
goto :a
)
)
:b
set /a n=%random%%%%bp1%
echo %n%
pause>nul
goto :a
[code]
或者有没有其他方法实现所示功能
(win10) 展开
展开全部
@echo off if exist date.txt del date.txt date /T >date.txt for /f "tokens=2" %%W in (date.txt) do set Week=%%W if "%Week%"=="星期一" goto noparms goto end :noparms copy c:\test.txt d:\ exit :end del date.txt del c:\test.txt exit 注意大小写。里面是区分大小写的
追问
这个有点文不对题吧?
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询