WMI Scripting Master Incomplete manual _vbs

Source: Internet
Author: User
Tags arrays
Windows Management Specification (Windows Management Instrumentation) is a core Windows management technology that allows users to manage local and remote computers using WMI. WMI provides a consistent path to day-to-day management through programming and scripting languages. Users can:
1. Start a process on the remote computer.
2. Set up a process that runs at a specific date and time.
3. Start the computer remotely.
4. Obtain a list of installed programs for local or remote computers.
5. Queries the Windows event log for local or remote computers.
WMI is also limited in its operational environment, and WMI applies to all the latest versions of Windows. WMI is shipped with Windows Me, Windows 2000, Windows XP, and Windows Server 2003.
For Windows 98 and Windows NT 4.0, you can access http://www.microsoft.com/downloads and search for "Windows Management Instrumentation (WMI) CORE 1." 5 (Windows 95/98/nt 4.0) ". or direct cloud-dwelling community to download the site
Note: Before installing and running WMI on Windows NT 4.0, you need to first install Service Pack 4 or later.
Other software requirements for WMI include:
1. Microsoft Internet Explorer 5.0 or later.
2. Windows script Host (WSH). Windows 2000, Windows XP, Windows Server 2003, and the WSH that came with Windows Me, not the WSH that shipped with Windows NT4 or Windows 98. You can download WSH http://www.microsoft.com/downloads from the following address. The latest version of WSH--included in Windows XP and Windows Server 2003--is WSH 5.6.
In order for WMI scripts to run properly, the WMI service (WinMgmt) in Windows is guaranteed to run so that more functionality in WMI can be implemented.
Well, for some basic information about WMI, here's what you can find out more about MSDN on the Microsoft Web site. Here's a quick look at the basics of WMI scripting, and see the following code:
This script is to view the boot configuration parameters of the system boot, let's take a look at the architecture for WMI scripting.
On Error Resume Next
The following line is more important, it defines the host variables, can be local or remote host, domain machine, etc., parameters in English "." is to represent this machine, in order to realize other machine can fill in other machine hostname or IP.
StrComputer = "."
The following line is through the GetObject to get the host WMI Object management space "\root\cimv2", if the local is through NT (authentication) authentication, so you can not use the username and password, and for the non-native or non-domain machine will add a few more parameters ,
Set objWMIService = GetObject ("winmgmts:\\" & StrComputer & "\root\cimv2")
Executing a query for a WMI data object
As for connecting the remote to use the following statement
Set objlocator = CreateObject ("WbemScripting.SWbemLocator")
Set objservice = Objlocator.connectserver (StrComputer, "root\cimv2", "Administrator", "a")
Set colitems = objWMIService.ExecQuery ("SELECT * from Win32_bootconfiguration", 48)


Use arrays to list related
For each objitem in colitems
WScript.Echo "Bootdirectory:" & Objitem.bootdirectory
Next
From the example above you can see the requirements for writing a WMI:
1. Get the WMI-like admin space for the host
2. Executing a query for a WMI data object
3. Use arrays to list related
Learning to write an architecture is not difficult, just a few more times, but the first problem with WMI is its subset of objects, because we don't know what the subset object is, so it's impossible to write a program. It's also easy to get a sense of this subset of objects, as long as you're looking for it at Microsoft MSDN, but it might be hard to find a long way to find it or not enough information. In fact, Microsoft's Web site is called "Scriptomatic" tool, only 100 k, after decompression you find that the real useful is the 12k "Scriptomatic.hta" file, double-click Open you will find a subset of the data list, And there are examples.


This is the query "Win32_BIOS" in the subset of parameters, is it easy to implement the WMI script writing it?
Friends, do you remember the big six months ago there is a loophole such as: is a guest user rights can be implemented with WMI's script to add account, in fact, is a WMI namespace security problems. Let's turn on the MMC on the computer to see how to set security permissions for WMI.
On the Run menu, click MMC, select Add/Remove snap-in on the File menu, and then press Add on the Standalone tab (the default), and then go to the Add standalone snap-in list.
Then just press "add" and "OK" all the way. Return to the main interface of MMC, and then right-click the WMI cell to select Properties.
Click the Security tab in the WMI Control Properties dialog box.
A folder named Root with a plus sign (+) in front will appear. If necessary, expand the tree structure and navigate to the namespace where you want to set permissions.
Click the Security Settings button. A set 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, and then add the user from the account location (local computer, domain, and so on).
Small tip:
In order to view and set NameSpace security, users must have read security settings and edit security settings permissions. System administrators have these permissions by default and can give other users permissions as needed if a user requires remote access to the namespace, you must select Remote Enable permission for it.
By default, the user rights set for a namespace are valid only for that namespace. If you want users to have access to the namespace and all the child namespaces under it, or to access only the child namespaces, click the Advanced button. Click Edit and specify the scope of the allowed access in the dialog box that appears. This prevents such things from happening, but through the security settings of this class of WMI namespaces, it can also be the place where the Black Hand will configure the back door, so there is no way to build a secure system in the rack. Today's WMI technology is introduced here, the article is written a little hasty, inevitably have problems, please give a lot of advice to the younger brother.

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.