编写脚本,以便在返回某个值时打开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!"
答案 0 :(得分:0)
只是对事物采取行动,不确定你想要什么 - 我通过 :: 评论了你的几行,并添加了替换。以下内容至少应该根据收到的来自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!"