编写脚本,以便在返回某个值时打开cmd。然后使用用户添加的值自动在cmd中运行命令。 不确定这是否可能,但任何帮助将不胜感激。谢谢
已编辑 - 之前的代码
:OpekaiNetReset
echo "Target IP; host is DOWN!"
echo Enter your target IP
set/p TargetIP="Enter your target IP"
ping %TargetIP%
IF %TargetIP%==packets recieved +1 start cmd.exe
IF %TargetIp%==packets recieved 0 goto OpekaiNetReset
:OpekaiCMD
cls
echo "Target IP; host is UP!"
只是对事情有所了解,不确定你想要什么 - 我通过 :: 注释掉了你的几行,并添加了替换。 下面至少应该根据从 ping 收到的数据包告诉您主机是否启动/关闭。 不确定在特定计数上运行cmd.exe是什么意思? 如果收到的数据包计数为 1,则以下命令运行命令。
:OpekaiNetReset
echo "Target IP; host is DOWN!"
::echo Enter your target IP
set/p TargetIP="Enter your target IP: "
::ping %TargetIP%
set received=0
for /f "tokens=2 delims=," %%p in ('ping %TargetIP%^|find /i "received"') do set /a %%p
echo packets received == %received%
::IF %TargetIP%==packets recieved +1 start cmd.exe
if %received%==1 start cmd.exe & exit /b
::IF %TargetIp%==packets recieved 0 goto OpekaiNetReset
if %received%==0 goto OpekaiNetReset
:OpekaiCMD
cls
echo "Target IP; host is UP!"