WMI:
set owmi = GetObject ("winmgmts:" & _
"{impersonationlevel = impersonate, (shutdown )}! "& _
"\\. "& _
" \ Root \ cimv2 ")
set CNAs = owmi. execquery ("select * From win32_networkadapter")
for each ONA in CNAs
wscript. echo Ona. macaddress
next
features: Like an SQL statement, you can add a where statement, such as:
where (macaddress is not null) and (manufacturer <> 'Microsoft ')
another method of WMI:
set CNAs = GetObject ("winmgmts:" & _
"{impersonationlevel = impersonate, (shutdown )}! "& _
"\\. "& _
" \ Root \ cimv2 "). instancesof ("win32_networkadapter")
for each ONA in CNAs
wscript. echo Ona. macaddress
next
features: it feels like a namespace class generates an instance
to obtain all properties of win32_networkadapter, you can write
set ona = GetObject ("winmgmts:" & _
"{impersonationlevel = impersonate, (shutdown )}! "& _
"\\. "& _
" \ Root \ cimv2 "& _
": win32_networkadapter ")
for each oproperty in Ona. properties _
wscript. echo oproperty. name
next
This WMI contains the prefix: "winmgmts:"; Security Settings :"{......}! "; Computer name:" \. "; CIM namespace:" \ Root \ cimv2 "; WMI class name:": wmiclassesname ".
The result is only a class object that has not been instantiated yet.
Shutdown is unnecessary. It was originally used to test the reboot function of win32_operatingsystem. Later, I was afraid that I would restart it by double-clicking it, instead of using win32_networkadapter. However, I forgot the book, but I still don't want to understand it.