我正在嘗試創建一個批處理腳本,以允許識別網絡連接(已更新)。網絡適配器批處理標識
這是一個比我以前更簡單的版本,但是在調用if語句時遇到問題。
@echo off
wmic nic get NetConnectionID, NetConnectionStatus
set Connection=(wmic path Win32_NetworkAdapter Where AdapterTypeID=0)
set Status=(wmic path Win32_NetworkAdapter Where NetConnectionStatus=2)
IF %Connection% and %Status% (
echo %computername% is connected to the network via Ethernet Wired/Wireless
Pause
::exit /b 2
) ELSE (
echo %computername% is not connected to a Network
Pause
::exit /b 1
)
你會想要看看'if /?'的輸出 – SomethingDark
對不起,在評論中添加它,更新了問題 –