使用netsh wlan connect name="your network_name"
您可以請求連接到WiFi網絡,但無法確定您是否已連接。使用批處理,如何確定您是否連接到WiFi網絡?
因此,在批處理中,將檢查我是否連接到WiFi網絡的命令行是什麼? (WiFi網絡可以或可以不具有網絡接入。)還應該爲Mobile的熱點工作太]
如果已連接,它應該顯示YES
,
如果沒有連接,它應該顯示NO
,
因爲我想運行一個循環取決於我得到的結果。
那麼有人可以編寫好的工作批處理程序!和C++(如果可能的話太)
我曾嘗試:
WMIC /node: 」PutYourPCNameHere」 path WIN32_NetworkAdapter where (NetConnectionID="Wi-Fi") get NetConnectionStatus
,但我們不能把是否循環。所以我不知道如何進行!
和
@echo off
ECHO Checking connection, please wait...
PING -n 1 www.google.com|find "Reply from " >NUL
IF NOT ERRORLEVEL 1 goto :SUCCESS
IF ERRORLEVEL 1 goto :TRYAGAIN
:TRYAGAIN
ECHO FAILURE!
ECHO Let me try a bit more, please wait...
@echo off
PING -n 3 www.google.com|find "Reply from " >NUL
IF NOT ERRORLEVEL 1 goto :SUCCESS2
IF ERRORLEVEL 1 goto :TRYIP
:TRYIP
ECHO FAILURE!
ECHO Checking DNS...
ECHO Lets try by IP address...
@echo off
ping -n 1 216.239.37.99|find "Reply from " >NUL
IF NOT ERRORLEVEL 1 goto :SUCCESSDNS
IF ERRORLEVEL 1 goto :TRYROUTER
:TRYROUTER
ECHO FAILURE!
ECHO Lets try pinging the router....
ping -n 2 192.168.1.1|find "Reply from " >NUL
IF NOT ERRORLEVEL 1 goto :ROUTERSUCCESS
IF ERRORLEVEL 1 goto :NETDOWN
:ROUTERSUCCESS
ECHO It appears that you can reach the router, but internet is unreachable.
goto :FAILURE
:NETDOWN
ECHO FAILURE!
ECHO It appears that you having network issues, the router cannot be reached.
goto :FAILURE
:SUCCESSDNS
ECHO It appears that you are having DNS issues.
goto :FAILURE
:SUCCESS
ECHO You have an active Internet connection
pause
goto END
:SUCCESS2
ECHO You have an active internet connection but some packet loss was detected.
pause
goto :END
:FAILURE
ECHO You do not have an active Internet connection
pause
goto :END
:END
但是這不能工作在移動熱點(不包括互聯網)
我CMD小抄'的Netsh WLAN顯示interfaces'顯示您連接到了什麼。見'netsh wlan show /?'。 –
但我不能使用,如果條件與它兄弟。 –
「_So有人可以編寫好的工作批處理程序!!和C++(如果可能的話)_」 - SO不是一個代碼服務。顯示你已經嘗試了什麼,以及你在哪裏被卡住(目前,你的問題只涉及bash,而不是C++) –