如果没有连接,则通过批处理文件打开程序



我只想在没有互联网连接的情况下打开一个程序,并且我想用批处理文件来打开它。。我想到了这样的东西:

if (! www.google.com) {start myprogram.exe} 
else {echo "The computer is connected to the internet"} 

但我从来没有深入研究过命令窗口,有人能告诉我如何编写这个小"程序"吗?

在某个地方进行第一次ping,并检查ping是否有效。对于ping,errorlevel 1=失败,errorlevel 0=成功

ping -n 1 google.com > NUL
if errorlevel 1 (
    myprogram.exe
) else (
    echo The computer is connected to the internet
)
pause

最新更新