Several WMI statements

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.