In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
Editor to share with you how to use the WMI script, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!
The Windows Management Specification (Windows Management Instrumentation) is a core Windows management technology; users can use WMI to manage local and remote computers. WMI provides a consistent approach to day-to-day management through programming and scripting languages. Users can:
1. Start a process on the remote computing machine.
2. Set a process to run at a specific date and time.
3. Start the computer remotely.
4. Get a list of installed programs for the local or remote computer.
5. Query the Windows event log on the local or remote computer.
The shipping environment for WMI is also somewhat limited, and WMI applies to all the latest versions of Windows. WMI is included with Windows Me, Windows 2000, Windows XP, and Windows Server 2003.
For Windows 98 and Windows NT 4.0, you can visit http://www.microsoft.com/downloads and search for "Windows Management Instrumentation (WMI) CORE 1.5 (Windows 95/98/NT 4.0)". Or download directly from this site
Note: before you can install and run WMI on Windows NT 4.0, you need to 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). WSH that comes with Windows 2000, Windows XP, Windows Server 2003, and Windows Me, not WSH that comes 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.
For the WMI script to run properly, the WMI service (winmgmt) in Windows is guaranteed to be running, so that more functions in WMI can be achieved.
Well, that's all for some basic information about WMI. If you want to see more, you can go to MSDN on the MicroSoft website. Let's briefly talk about the basic elements of WMI scripting and take a look at the following code:
/ / this script is to view the boot configuration parameters of the system startup. Let's take a look at the architecture of WMI scripting.
On Error Resume Next
/ / the following line is important. It defines the variables of the host, which can be local or remote hosts, machines on the domain, and so on. It represents this machine. If you want to implement other machines, you can fill in the host name or IP of other machines.
StrComputer = "."
/ / the following line is to get the host's WMI object management space "\ root\ cimv2" through GetObject. If it is local, it is authenticated by NT (Authentication), so you can use no username and password, and add a few more parameters for non-local or non-domain machines.
Set objWMIService = GetObject ("winmgmts:\\" & strComputer & "\ root\ cimv2")
/ / execute the query of WMI data object
/ / for those who connect remotely, 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 the array to list the relevant
For Each objItem in colItems
Wscript.Echo "BootDirectory:" & objItem.BootDirectory
Next
From the above example, you can see the requirements for writing a WMI:
1. Get the WMI object management space of the host
2. Execute the query of WMI data object
3. Use the array to list the correlation
It's not difficult to learn the architecture you write, as long as you practice it a few times, but the first difficulty in learning WMI is its subset object, because we don't know what its subset object is, so you won't be able to write the program. It is not difficult to know the objects of such a subset at once, as long as you look for it in the MSDN of MicroSoft, there will be many, but if you go on looking like this, it may take a long time or the information is not complete enough, isn't it a bit difficult? In fact, there is a tool called "scriptomatic" on MicroSoft's website, which is just over 100k. After decompression, you find that what is really useful is the 12k "scriptomatic.hta" file. After double-clicking to open it, you will find that it is a subset of the data list, and there are examples.
These are the subset parameters in the query "Win32_BIOS". Is it easy to write WMI scripts?
Friends, do you remember that there was such a loophole more than half a year ago: an example in which GUEST user rights can be added with WMI scripts, which is actually a security problem with WMI namespaces. Let's open MMC on your computer and see how to set security permissions for WMI.
Type MMC on the run menu, then select add / remove snap-ins on the File menu, then press add on the separate tab (default), and then come to the add standalone snap-ins list.
Then just press "add" and "OK" all the way. Return to the main interface of MMC, then right-click the "WMI" cell and select "Properties".
Click the Security tab in the WMI control properties dialog box.
A folder named Root preceded by a plus sign (+) 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 location of the account (local computer, domain, and so on).
Tips:
In order to view and set NameSpace security, users must have permission to read and edit security settings. The system administrator has these permissions by default and can grant permissions to other users as needed. If a user needs remote access to the namespace, he must select remote enable permissions for him or her.
By default, user permissions set for one namespace are valid only for that namespace. If you want users to have access to the namespace and all subnamespaces below it, or only to subnamespaces, click the Advanced button. Click Edit and specify the range to which access is allowed in the dialog box that appears. This can prevent this from happening, but through the security settings of this kind of WMI namespace, it can also become a place where the black hand will configure the back door, so you have to look at it here to build a secure system.
The above is all the content of this article "how to use WMI script". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.