问题描述
我正在编写一个批处理脚本,其中应该区分Windows和非Windows系统(Linux,MAC OS,交换机,Xerox机器等).
I am writing a batch script wherein I am supposed to differentiate between Windows and Non-Windows systems (Linux, MAC OS, Switches, Xerox Machines, etc).
算法:
if (it is a Windows System)
then
do this
end if
为此,我尝试使用nbtstat
命令.据我所知,当执行nbtstat -A [IP Address]
时,如果[IP Address]
是Windows系统,它将显示如下输出:
In order to do that, I am trying to take help of nbtstat
command. As per my knowledge, when nbtstat -A [IP Address]
is executed, if [IP Address]
is a Windows system, it would display the output as follows:
>nbtstat -A 172.22.73.15
Local Area Connection:
Node IpAddress: [172.22.73.15] Scope Id: []
NetBIOS Remote Machine Name Table
Name Type Status
---------------------------------------------
MANDAR-PC <00> UNIQUE Registered
DOMAIN <00> GROUP Registered
MANDAR-PC <20> UNIQUE Registered
DOMAIN <1E> GROUP Registered
MAC Address = 00-1E-0B-9D-DD-E9
对于非Windows系统,输出为:
For a Non-Windows system, the output would be:
>nbtstat -A 172.22.246.51
Local Area Connection:
Node IpAddress: [172.22.73.15] Scope Id: []
Host not found.
如何使用nbtstat
或任何其他命令来区分Windows和其他系统?
How can I use nbtstat
or any other command in order to distinguish between Windows and other systems?
推荐答案
nbtstat -A 172.22.246.51 | find /i "Host not found." >nul 2>&1 && ( echo not a windows ) || (echo windows)
?
这篇关于批量区分Windows和其他系统的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!