Incomplete WMI script Manual

Source: Internet
Author: User
Tags microsoft website

Windows Management Instrumentation is a core windows management technology. You can use WMI to manage local and remote computers. WMI provides a continuous and consistent approach for daily management through programming and scripting languages. You can:
1. Start a process on the remote computer.
2. Set a process to run on a specific date and time.
3. Start the computer remotely.
4. Obtain the installed local or remote computer Program List.
5. query Windows event logs of local or remote computers.
WMI is applicable to the operating environment, and WMI is applicable to all the latest Windows versions. WMI is included in Windows ME, Windows 2000, Windows XP, and Windows Server 2003.
For Windows 98 and Windows NT 4.0, visit http://www.microsoft.com/downloadsand search for export Windows Management Instrumentation (Wmi) Core 1.5 (Windows 95/98/NT 4.0 )". Or download it directly from the script home site.
Note: before installing and running WMI on Windows NT 4.0, you must first install Service Pack 4 or later.
Other software required by WMI includes:
1. Microsoft Internet Explorer 5.0 or later.
2. Windows Script Host (wsh ). Windows 2000, Windows XP, Windows Server 2003, and wsh for Windows ME, instead of wsh for Windows NT4 or Windows 98. You can download the latest version of wsh http://www.microsoft.com/downloads. wsh from the following address-included in Windows XP and Windows Server 2003-is wsh 5.6.
To make the WMI script run properly, the WMI Service (Winmgmt) in windows must be running, so that more functions in WMI can be implemented.
All right, let's talk about some basic information about WMI. For more information, visit the Microsoft website's msdn. The following describes the basic elements of WMI script writing. Code :
// This script is used to view the boot configuration parameters of the system. Let's take a look at the architecture of WMI script writing.
On Error resume next
// The following line is important. It defines the host variables, such as local or remote hosts and machines in the domain. "indicates the local machine. to implement other machines, you can fill in the host name or IP address of other machines.
Strcomputer = "."
// The following line uses GetObject to obtain the WMI Object Management space "\ Root \ cimv2" of the host. If the host is authenticated by NT (authentication, therefore, you do not need a user name or password, but add several more parameters for non-local or non-domain machines,
Set ob1_miservice = GetObject ("winmgmts: \" & strcomputer & "\ Root \ cimv2 ")
// Query the WMI data object
// Use the following statement for remote connection
Set objlocator = Createobject ("wbemscripting. swbemlocator ")
Set objservice = objlocator. connectserver (strcomputer, "Root \ cimv2", "Administrator", "")
Set colitems = obw.miservice. execquery ("select * From win32_bootconfiguration", 48)

// list related items using arrays
for each objitem in colitems
wscript. echo "bootdirectory:" & objitem. bootdirectory
next
the following example shows the requirements for writing a WMI:
1. obtain the WMI image management space of the host
2. query WMI data objects.
3. using arrays to list related
it is not difficult to learn the written architecture. You only need to practice it several times. However, the first difficulty in learning WMI is its subset object, because we don't know what its subset object is, writing a program will be powerless. It is not difficult to know such a subset of objects at once. As long as there are many objects in Microsoft's msdn, it may take a long time to find them or the information is not full enough. Isn't it difficult? In fact, there is a tool named "scriptomatic" on Microsoft's website, which is more than 100 K. After decompression, you find that what is really useful is the "scriptomatic" of the only 12 K. "HTA" file. After double-clicking it, you will find that it is a subset of the Data list, and there are examples.

the preceding section describes the subset parameters in "win32_bios". Is it easy to write WMI scripts?
my friends, do you remember that most of the years ago there was a vulnerability like this: an example of how a guest user can use WMI scripts to add accounts, it is actually a problem with the security of a WMI namespace. Next, open MMC on the computer to see how to set WMI security permissions.
click "MMC" on the running menu, select "Add/delete Management Unit" on the "file" menu, and then click the "independent" tab (default) click "add" and then go to the "add independent management unit" list.
click "add" and "OK. Return to the main interface of MMC, and right-click the "WMI" unit and select "properties ".
In the WMI Control Properties dialog box, click the Security tab.
A folder named root with the plus sign (+) in front will appear. Expand the tree structure if necessary and locate the namespace to which you want to set permissions.
click Security Settings. A group of users and permissions are displayed. If the user is in this list, modify the permissions as needed. If the user is no longer in this list, click the Add button to add the user from the account location (local computer, domain, etc.
tips:
to view and set namespace security, you must have read Security Settings and edit security settings. By default, the system administrator has these permissions and can grant permissions to other users as needed. If a user needs to remotely access the namespace, the system administrator must select the remote enable permission for the user.
by default, user permissions set for a namespace are only valid for this namespace. To access the namespace and all its sub-namespaces, or to access only the sub-namespaces, click the Advanced button. Click Edit and specify the allowed access range in the displayed dialog box. This will prevent such incidents. However, the security settings of such WMI namespaces can also be used by black hands to configure backdoors. Therefore, a secure system is built on the shelf, you cannot skip this step. Today's WMI Technology is introduced here. The Article is written in a rush, so it is inevitable that there will be problems. Please give me some advice.

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.