微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

如何将变量与某个值进行比较,如果它具有该值,则脚本应在 CMD 中继续

如何解决如何将变量与某个值进行比较,如果它具有该值,则脚本应在 CMD 中继续

我已经在我的 .batch 文件中尝试过这段代码

@echo off
Title Ping
color b
echo Enter the website you would like to ping
set input=
set /p input= Enter your Website here:
color d
echo Enter the password for the program
set input2=
set /p input2= Enter the Pass here:
color b
IF [input2] EQU [1234] 

它应该检查 Input2 是否等于 1234,如果是,脚本应该继续,如果它不等于 1234 就应该等待。

我想这很简单,但我似乎没有让它工作。脚本也只是在最后一行代码之后崩溃。

解决方法

好的,我花了一些时间在代码上,我想我现在完成了。

@echo off
Title Ping
color b
echo Enter the website you would like to ping
set input=
set /p input= Enter your Website here:
set input2=
set /p input2= Enter Password here:
if /I "%input2%" NEQ "1234" GOTO END
setlocal
:PROMPT
set AREYOUSURE=
SET /P AREYOUSURE=Are you sure (Y/[N])?
IF /I "%AREYOUSURE%" NEQ "Y" GOTO END
set x=
set /p x= How many times you like to ping?
color c
cls
echo -------------------------------------------------------------
echo now pinging %input% %x% times press strg + c to cancel
echo -------------------------------------------------------------
color a
ping -l 65500 -n %x% %input%

:end 
endlocal

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其他元素将获得点击?
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。)
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbcDriver发生异常。为什么?
这是用Java进行XML解析的最佳库。
Java的PriorityQueue的内置迭代器不会以任何特定顺序遍历数据结构。为什么?
如何在Java中聆听按键时移动图像。
Java“Program to an interface”。这是什么意思?