Release Date: 09/03/2004 | Update Date: 09/03/2004
Greg Stemp, Dean Tsaltas and Bob Wellsmicrosoft Corporation
Ethan Wilansky Network Design Group
Summary: The first Scripting Guys of Scripting Guys demonstrates how to create a large number of useful Windows system management scripts using the WMI script library.
This page
What is WMI? Quick start to WMI script WMI architecture hosting resource WMI infrastructure browsing CIM is here
Microsoft® Windows® Management Instrumentation (WMI) is probably the best secrets we knows Microsoft saved. Despite this, there is no doubt that WMI is Microsoft's main management support technology for Windows. What does this mean for you? So, if you manage Windows Server and Workstations, or if you create a Windows management application, you need to know WMI. This article is a professor you WMI, more precisely, teach you how to use the WMI script library to create a large number of Windows system management scripts in the series of articles in the series of articles.
Before starting, we should use the Andrew Clinick, which makes us have the opportunity to inherit Scripting Clinic. It can be said that when Andrew said in its recent column, he is not a joke when he plans more content! In fact, Andrew is moving to another, so he politely invited us to continue from him. In addition to the beginning of the start, we are very reluctant because Andrews Scripting Clinic is very reluctant, we are very happy to take over.
So, who are we? We are Scripting Guys, which is a group written by the System Administration Scripting Guide, which is part of the Microsoft® Windows Server 2003 resource toolbox. In the big head in the column, the left is DEAN, and the right side is Greg. There are rumors that Ethan and Bob have missed the photo due to wrinkles every week of botulinum. So, if you see their photos on the Internet, they found that they look very handsome. We have to tell you here, Ethan and Bob are really the most stupid guys we have seen! Remember to pay attention.
What is WMI?
WMI was initially issued as an additional component as an additional component in 1998, which is built in the core management support technology in Windows 2000, Windows XP, and Windows Server 2003 Series operating systems. Based on the industry standard supervised by Distributed Management Task Force (DMTF), WMI is a normative and infrastructure that can be accessed, configured, managed, and monitors all - almost all Windows resources.
To master the powerful features and scope of WMI, consider how to manage and monitor Windows workstations and servers before (or now). You may use many graphical management tools to manage Windows resources - such as disks, event logs, files, folders, file systems, network components, operating system settings, performance data, printers, processes, registry settings. , Security, service, sharing, user, group, etc.
Although the graphical tool provides a functional management solution, what is the things share? A answer is that before WMI, all Windows graphics management tools rely on the Win32 application programming interface (Application Programming Interface, APIS) to access and manage Windows resources. why? Because the only way to access Windows resources in programming methods is to pass the Win32 API. This situation allows Windows system administrators to automate commonly used system management tasks through a simple way to use common scripting languages because most scripting languages cannot call Win32 API directly. By providing consistent models and frameworks, WMI changes this - through models and frameworks, all Windows resources are described and disclosed to the outside world. The best point is that system administrators can use the WMI script library to create system management scripts, and manage any Windows resources exposed through WMI! Using Windows Script Host and Microsoft Visual Basic Scripting Edition (VBScript), or any scripting language that supports COM (for example, ActiveState Corporation ActivePerl), you can write scripts to manage and automate the following aspects of enterprise systems, applications, and networks:
• Windows Server 2003, Windows XP Professional and Windows 2000 System Management. You can write scripts to retrieve performance data, manage event logs, file systems, printers, processes, registry settings, schedulers, security, services, sharing, and many other operating system components and configuration settings. • Network management. You can create a WMI-based script to manage network services, such as DNS, DHCP, and devices that enable SNMP. • Sound monitoring in real time. Using WMI event subscriptions, you can write code to monitor and respond to event log items, monitor and respond to event log entries, monitor and respond to file systems, registry modifications, and other real-time operating system changes. Basically, WMI event subscriptions and notifications are what SNMP traps are in the SNMP environment. • Windows .NET Enterprise Server Management. You can write scripts to manage Microsoft Application Center, Operations Manager, Systems Management Server, Internet Information Server, Exchange Server, and SQL Server.
Back to top
Quickly start to WMI scripts
In order for you to have some concepts for WMI scripts, let's take a look at a surface that is not very important task - retrieves the total amount of physical memory installed in Windows-based remote computers. Before WMI, if there is no additional third-party tool, it cannot be easily completed by a script. In fact, before WMI, use tools including operating system tools to determine the only way to install the number of memory in your computer is through the System Properties dialog box. Today, if WMI is installed on the target computer, and there is a computer administrator access, you can use a WMI script to retrieve physical memory installed on a remote Windows computer, as simple as shown in Listing 1.
Listing 1: Search total physical memory using WMI and VBScript
STRComputer = "ATL-DC-01"
Set WbemServices = getObject ("WinMgmts: //" & strComputer)
SET WBEMOBJECTSET = WBEMSERVICES.INSTANCESOF ("Win32_LogicalMemoryConfiguration" for Each WbemObject in WbemObjectset
WScript.echo "Total Physical Memory (KB):" & WbemObject.totalphysicalMemory
NEXT
To run the sample scripts in Listing 1, copy them and paste them into your most common text editor (NotePad.exe), change the value assigned to the StrComputer variable to a valid enable WMI computer in the domain, Save the script (extension is .vbs) and run the script as shown in Figure 1.
Figure 1: GetMemory.vbs output
It is a bit incredible, there is no need to enter, you should see the physical memory volume of the target computer is displayed.
Now, in you say "God! Really use six lines of scripts to search for the amount of memory in a computer?" Before, let us first politely plug in a few words, because it is still not obvious, you can use it. The same basic steps shown in Listing 1 are retrieved from any Windows resource through WMI.
Suppose you want to retrieve the name, status, and start type of all services installed on a remote computer. The example script in Listing 2 is completely used in the same basic steps used in Listing 1.
Listing 2: Search service information using WMI and VBScript
STRComputer = "ATL-DC-01"
Set WbemServices = getObject ("WinMgmts: //" & strComputer)
SET WBEMOBJECTSET = WBEMSERVICES.INSTANCESOF ("Win32_Service")
For Each WBemObject in WbemObjectset
WScript.echo "Display Name:" & WbemObject.displayName & VBCRLF & _
"State:" & WbemObject.State & Vbcrlf & _
"START MODE:" & wbemObject.Startmode
NEXT
Run list 2 Generates the output as shown in Figure 2.
Figure 2: GetServices.vbs output
Suppose you are not interested in the service, but you need to retrieve records from the Windows event log. Use the script template in Listing 1 again, you can easily read the Windows event log, such as the presentation shown in Listing 3. We have to point out before you run a list 3, if your event log contains thousands of records, the sample script may take a long time to run.
Listing 3: Read Windows Event Log Record
STRComputer = "ATL-DC-01"
Set WbemServices = getObject ("WinMgmts: //" & strComputer)
Set wbemObjectset = WbemServices.instancesof ("Win32_NTLOGEVENT")
For Each WBemObject in WbemObjectset
WScript.echo "log file:" & wbemobject.logfile & vbcrlf & _ "Record Number:" & WbemObject.RecordNumber & Vbcrlf & _
"TYPE:" & WBEMOBJECT.TYPE & VBCRLF & _
"Time generated:" & wbemObject.timegenerated & vbcrlf & _
"Source:" & WbemObject.Sourcename & Vbcrlf & _
Category: "& WbemObject.category & vbcrlf & _
Category String: "& WbemObject.categoryString & Vbcrlf & _
"Event:" & WbemObject.Eventcode & VBCRLF & _
User: "& WbemObject.user & vbcrlf & _
"Computer:" & wbemObject.computername & VBCRLF & _
Message: "& wbemObject.Message & vbcrlf
NEXT
If we carefully check the list 1, 2 and 3, we will draw two very important observations about these three scripts. The first observation result is that all three scripts perform the same three steps: scripts connected to WMI, retrieve a WMI managed resource, and returns several properties of resources. The second important observation result is that in each script, the only change is identifying the class name of the target resource (ie, Win32_LogicalMemoryConfiguration, Win32_Service, and Win32_NTLOGEVENT), and the corresponding properties of the resource.
Three steps used in the script are common for any WMI script used to retrieve WMI hosting resource information. Let's take a slightly more detailed look at each step.
Step 1: Connect to WMI Services
In any WMI script, the first step is a connection to the Windows management service on the target computer. Connect to WMI on a local or remote computer and call VBScript's getObject function and the name of the name object of the WMI script (ie "WinMgmts:", the name of the target computer is as simple as the GetObject.
Connect to WMI in this way, returns a reference to the SwbemServices object, and we use the variables called WBEMServices in Listing 1, 2, 3 to reference the object. SwbemServices is one of the left and right objects defined in the WMI script library. The WMI script library provides a set of universal object scripts for accessing the WMI infrastructure. Once there is a reference to the SwbemServices object, you can call any way to provide SWBEMServices; InstanceSof is one of this method.
Step 2: Retrieve the instance of WMI hosting resources, the second step is mainly dependent on the task to be executed. In the information of the WMI hosted resource, step 2 is as simple as the instancesof method that calls the SwbemServices object. As the method name is indicated, instancesof returns all instances of managed resources identified by the resource class name. Instancesof returns the required resources in the form of a SwbemObjectset collection, and we reference it in Listing 1, 2, 3 by using variables named WBemObjectSet. SWBemObjectSet is another script object defined in the WMI script library.
Step 3: Display the properties of the WMI managed resource
The last step is to enumerate the contents of the SwbemObjectSet collection. Each of the SWBemObjectSet is a SwbemObject (another object in the WMI script library) - a single instance indicating the desired resource. Use SwbemObject to access the methods and properties defined in the managed resource class definition.
Then, what is the same, Win32_LogicalMemoryConfiguration, win32_service, and Win32_NTLOGEVENT classes? In addition, where are they from? Which other classes are available? Also, how to use them? The answers to these problems are dispersed in each component constituting the WMI architecture. Let's take a look.
Back to top
WMI architecture
The WMI architecture consists of three main layers, as shown in Figure 3:
• Managed resources • WMI infrastructure • Users
Figure 3: WMI architecture
We will start from the lowest layer, because the resources are residing there.
Back to top
Hosted resources
The hosted resource is an arbitrary logic or physical component, which is publicly and managed by using WMI. You can use WMI-managed Windows resources including: computer system, disk, peripherals, event logs, files, folders, file systems, network components, operating system subsystems, performance counters, printers, processes, registry settings, security, Services, sharing, SAM users, groups, Active Directory, Windows Setup, Windows Driver Mode (WDM) Device Drivers, and SNMP Management Information Basis (MIB) data, etc. WMI hosted resources communicate with WMI via a provider. When you start writing a script to interact with the WMI hosted resource, you often see a term example, which is used to reference the virtual representation of the managed resource in the running script.
Back to top
WMI infrastructure
The intermediate layer is a WMI infrastructure. WMI consists of three main components: a common information model object manager (CIMM), a common information model (CIM) repository, and provider. These three WMI components jointly provide an infrastructure that is defined, disclosed, access, and retrieves configuration and management data. Although small, the fourth component that is absolutely indispensable to write scripts is the WMI script library.
WMI provider
The WMI provider plays an intermediate role between WMI and managed resources. The provider represents the user application and script request information from the WMI managed resource, and sends instructions to WMI managed resources. For example, Listing 1 and Listing 2 use a built-in WIN32 provider to retrieve memory and service related information. Listing 3 Use the built-in event log provider to retrieve records from the Windows event log.
By publicizing the hosted resource to the WMI infrastructure based on WMI standard, a uniform access model, providing a program hidden hosted resource unique implementation details. The WMI provider uses the host API to communicate with the WMI programming interface using the WMI programming interface. For example, the built-in event log provider calls the Win32 event log API to access the event log. WMI-based scalable architecture, software developers can develop and integrate additional providers to disclose their product unique management functions. The Exchange Server 2000 provider for monitoring the Exchange Connector status is an example. Similarly, both Application Center, Operations Manager, Systems Management Server, Internet Information Server, and SQL Server include WMI providers.
The provider is usually implemented as a dynamic link library (DLL) in the% SystemRoot% / System32 / WBEM directory. WMI includes a lot of built-in providers for Windows 2000, Windows XP, and Windows Server 2003 Series operating systems. Built-in providers (also known as standard providers), provide data and management functions from known operating system sources such as Win32 subsystems, event logs, performance counters, registry, etc.). Table 1 lists a WMI provider included in Windows 2000, Windows XP, and Windows Server 2003 Series operating systems.
Table 1: Some standard WMI Provider List Provider DLL Namespace Description Active Directory Provider DSPROV.DLL ROOT / DIRECTORY / LDAP maps the Active Directory object to WMI. Event Log Provider NTEVT.DLL ROOT / CIMV2 Manage Windows Event Logs, for example, read, backup, cleaning, copying, deleting, monitoring, rename, compression, decompression, and changing event log settings. Performance Counter Provider Wbemperf.dll Root / CIMV2 provides access to raw performance data. Registry Provider STDPROV.DLL ROOT / DEFAULT Read, Write, Enumeration, Monitor, Create, Delete Registry Item and Value. SNMP Provider SNMPincl.dll Root / SNMP provides access to SNMP MIB data and captures from SNMP managed devices. WDM Provider WMIPROV.DLL ROOT / WMI provides access to information in the WDM device driver. Win32 Provider CIMWIN32.DLL ROOT / CIMV2 provides information about computers, disks, peripherals, files, folders, file systems, network components, operating systems, printers, processes, security, services, sharing, SAM users, and groups, and more Multi-resource information. Windows Installer Provider MSIPROV.DLL ROOT / CIMv2 provides access to installed software information.
Windows XP and Windows Server 2003 contain a lot of additional standard providers. For a complete list of standard providers, see the WMI Provider Reference in the WMI Software Developers Kit (SDK) document.
CIMOM
CIMOM (read as a SEE-MOM) handles interactions between users and providers. This term is from the web-based enterprise management software and the public information model specification maintained by Distributed Management Task Force.
You can imagine the CIMOM as a WMI information agent. All WMI requests and data have passed CiMom. Windows Management Instrumentation Services (WINMGMT.exe) provides a CIMOM role on Windows XP and Windows Server Series operating systems, running under the control of the General Service Host Process (SVCHOST.exe). Note On the computer running Windows 2000 or Windows NT 4.0 Service Pack 4, WMI service is run as a separate service process. On the computer running Windows Millennium Edition (ME), Windows 98, or Windows 95 OSR 2.5, WMI is run as a standard executable process.
In addition to providing public interfaces (users from accessing WMI), CIMOM also provides the following core services to the WMI infrastructure:
• Provide registration. WMI provides registration position and function information using CiMom. This information is stored in the CIM repository. • Request to be transmitted. CIMOM uses the provider registration information to transfer the user request to the appropriate provider. • remote access. Users access remote systems that enable WMI through CIMOM access to the remote system. Once the connection is established, the user can perform the same operation as the operation that can be performed locally. • safety. On the local computer or on a remote computer, the user is allowed by verifying access tags of each user before connecting to WMI, and CIMOM controls access to WMI managed resources. WMI does not override or blocks the security provided by the operating system. • Query processing. Allow users to use WMI query language (WMI Query Language, WQL) to issue queries about any WMI managed resource. For example, you can query all event logs that occurred in an event that occurred in the past 24 hours. CiMOM executes the query calculation only if the provider itself does not support query operations. • Event processing. Allow users to subscribe to events that represent changes to the WMI managed resource. For example, you can subscribe to an event indicating when the space on the logical disk drive drops below an acceptable threshold. CICOM is polled in a specified interval, and an event notification is generated when the subscription condition is met.
Managing applications, management tools, and scripts to transfer CiMom to minimize data, subscribe to events, or perform some other related tasks. CIMOM obtains the required provider and class information to meet the user's request from the CIM. CIMOM uses information obtained from the CIM to pass the user's request to the appropriate provider.
CIM repository
The basic idea of WMI is - can be unified in one architecture to represent configuration and management information from different sources. CIM is this architecture, also calls the model managed environment and defines the object repository or class storage of each data block published by WMI. This architecture is based on the DMTF public information model standard.
It is very similar to the architecture of Active Directory based on classes, and CIM consists of classes. Class is a blueprint for a WMI hosted resource. However, different from the Active Directory class represents an object created and stored in the directory, and the CIM class usually represents dynamic resources. That is, the example of the resource is not stored in the CIM, but is dynamically retrieved by the provider based on the user request. It is very simple, and most WMI managed resources have changed very frequently, so you must read it on demand to ensure that the retrieval is the latest information.
In the context of CIM, the term repository is somewhat misunderstood. Although the CIM is a repository, it is possible to store static data, but its main role is a blueprint for storing the hosted resource.
Similar to the Active Directory class is that the CIM class is a hierarchical organization, and the subclass of each level is inherited from the parent class. DMTF maintains a set of cores and public base classes, systems, and applications software developers (such as Microsoft) from these class derived and created system (or application) specific extensions. The class is packet into the namespace, and the namespace is a class logical group representing a specific management area. For example, namespace Root / CIMv2 includes most of the classes that are typically associated with the computers and operating systems. The class (Win32_LogicalMemoryConfiguration, Win32_LogicalMemoryConfiguration, Win32_LogicalMemoryConfiguration, Win32_LogicalMemoryConfiguration, Win32_Service, and Win32_NTLOGEVENT) resides in Namespace Root / Cimv2, which is just three of hundreds of classes defined in the CIM.
The CIM class consists of attributes and methods. The property describes the configuration and state of the WMI hosted resource, and the method is the executable function of the operation on the WMI managed resource.
Note Do not confuse the methods and properties defined by the CIM with the method and properties provided by the automation objects in the WMI script library.
From the physics school, CIM resides in% systemroot% / system32 / wbem / repository / fs / directory, consisting of the following four files:
• INDEX.BTR. Two-Binary index file. • INDEX.MAP. Transaction control file. • Objects.data. Store the CIM repository defined by the hosted resource. • Objects.map. Transaction control file.
Note In Microsoft Windows 2000 and Windows NT 4.0 Service Pack 4, CIM is stored in% SystemRoot% / System32 / WBEM / Respository / Cim.rep. In Windows Millennium Edition (ME), Windows 98, and Windows 95 OSR 2.5 operating systems, CIM is stored in% Windir% / System / WBEM / Respository / Cim.rep.
Although CIM is based on object-oriented design principles, you don't have to be an expert in information modeling or architecture design, you can effectively use WMI and write WMI-based scripts. It is important to understand the infrastructure and organization of CIM and learn how to browse and explain its content.
WMI script library
The WMI script library provides automated object sets, scripting languages (such as VBScript, JScript, and ActivePerl ActivePerl) use it accesses the WMI infrastructure.
The automation object in the WMI script library provides a consistent and unified script model for the WMI infrastructure. As shown in front, once you know how to use the WMI script library to search for a managed resource type, you can easily use the same steps to retrieve other WMI managed resources. For example, you can use any of the three scripts listed above and easily modify this script to retrieve the process (Win32_Processor) information, processor (Win32_Processor) information, operating system (Win32_Operatingsystem) on remote computers (WIN32_PROCESSYSTEM) Information, or any one of hundreds of hosted resources disclosed by WMI.
The WMI script library is implemented in a single DLL called Wbemdisp.dll, which is located in the% systemroot% / system32 / wbem directory. The WMI script library also includes a type library called WBEMDisp.tlb. You can use the WMI script type library to reference the WML constant from an XML-based Windows script file (extension. WSF).
WMI user
Users are top. Users are scripts, enterprise management applications, web-based applications, or other management tools, which access and control usable information through WMI infrastructure. Note Many management applications act as a dual role of WMI users and WMI providers. There are several Microsoft management products that belong to this situation, such as Application Center, Operations Manager, and Systems Management Server, and SYSTEMS Management Server.
Back to top
Browse CIM
We have discussed a considerable part of the content, but there is still a detail without talking, however, how to determine which resources are public through WMI. Fortunately, you can use a variety of different tools to browse the CIM architecture and check the class definition of the WMI managed resource.
• WMI control. WMI Control (WMIMGMT.MSC) is a Microsoft Management Console (MMC) snap-in, which allows you to configure WMI settings on your local or remote computer. Although you cannot use the WMI control to browse CIMs, you can use the "Security" tab of this tool to determine the CIM namespace available on the local or remote computer. For more information on using WMI controls, see Windows 2000 Help or Windows XP Help and WMI control over the support center. • WMI tester. WMI Tester (WBEMTEST.exe) is a common, graphical tool for interacting with WMI infrastructure. You can use the WMI tester to browse the CIM architecture and check the managed resource class definition. The WMI tester can also be used to perform the same operations as WMI-based scripts, such as instances and running queries that search hosted resources. The WMI tester is part of the default WMI installation on all WMI-enabled computers, so Wbemtest.exe is an excellent WMI learning and troubleshooting tool. For information on using the WMI tester, see the WMI Tester Overview in Windows XP Help and Support Center. • WMI command line. The WMI command line tool (WMIC.exe) that is released as part of Windows XP provides a command line interface to the WMI infrastructure. You can use WMIC.exe to execute common WMI tasks from the command line, including browsing CIM and check the CIM class definition. For information on using the WMI command line tool, see "Using WMI Command Line (WMIC) Tools" in Windows XP Help and Support Center • CIM Studio. As part of the WMI SDK, CIM Studio provides a web-based interface implementation with WMI infrastructure interaction. As with the WMI tester, you can use CIM Studio to view the CIM architecture, view the class definition and retrieve the instance of managed resources. The class relationship and association can be easily viewed by the CIM Studio's super user interface, and CIM Studio provides a basic search tool - they are both of the WMI tester tools. To use CIM Studio, you must download and install WMI SDK. You can download WMI SDK from Windows Management Instrumentation (WMI) SDK. • Enumclasses.vbs and enuminstances.vbs. The Windows 2000 Server Resource Toolbox includes a lot of scripts that use WMI powerful features. The three scripts listed here are common scripts that can be used to browse the CIM architecture, view the class definition, and retrieve an instance of managed resources.
Some additional resources you should view include:
• WMI SDK documentation. The WMI SDK contains a complete list of classes provided by the standard WMI provider. You can access the WMI SDK document in the MSDN online library. • TechNet Script Center. If you like, you can call it useless, but the TechNet Script Center contains hundreds of WMI-based sample scripts from the upcoming System Administration Scripting Guide. WMI Tester (WBEMTEST.EXE) drill
Now, you have some knowledge of tools that can be used to browse and see CIM, let us use the WIN32_PROCESS class definition and modify the list of processes from your local computer. Retrieve some properties.
1. Open a command prompt, type C: /> Wbemtest.exe, press Enter to start the WMI Tester Tool. Note that most of the buttons are disabled on the main WMI tester window, indicating that you are not connected to WMI. 2. Click Connect to connect to WMI services on your local or remote computer. The Connection dialog is displayed, which provides a text input area tagged as NameSpace, the default value of Root / Default. Change the value of the NAMESPACE area to root / cimv2, click the Connect button of the Connection dialog to return to the main WMI Tester window. 3. The namespace identifier in the upper left corner of the main window should be displayed as root / cimv2. Note that all buttons are now enabled, which indicates that you have successfully connected to WMI on your local host in the current credential environment. Click ENUM CLASSES to open the "Super Class Information" dialog. 4. In the "Ultra Class Information" dialog box, don't fill in the Enter Superclass Name area, click the Recursive option, click OK to enumerate all CIM classes defined in the root / cimv2 namespace. At this point, you may be viewing a Query Results dialog listing hundreds of classes defined. The number of classes depends primarily on the version of Windows you are running. For example, if you use Windows 2000, you should see approximately 600 class definitions. If you run Windows XP, you should see about 900 classes definitions. Note that the class listed in the top of the "Query Result" dialog is starting with two underscores. These are system classes. The system class is a predefined CIM class that supports internal WMI configuration and operation, such as providing program registration, namespace security, and event notifications. Now, ignore the system class and scroll down the Query Results dialog until you see the class starting with CIM_. The name starting with CIM_ is the core and public base class maintained by DMTF. Continue to scroll down until you reach the class starting with Win32_. The name starting with Win32_ is a Microsoft extension class that represents Windows-specific managed resources. If this is your first time to check the root / cimv2 namespace, you may want to be familiar with the full collection of classes in the root / cimv2 namespace, especially if there is a class of Win32_ prefix. 5. Scroll down the "Query Result" dialog until you reach the Win32_Process class, double-click the class name to open the object editor of the Win32_Process dialog. 6. The Object Editor dialog displays details (properties and methods) of the definitions and implementations of the selected classes. Recall the content we discussed before - class definition is a blueprint for WMI manageable resources. Select Hide System Properties check box to hide system properties. The remaining Win32_Process property indicates information you can retrieve from a process running on a local or remote computer. To complete your WMI script exercise, try to retrieve the Name, Handle, and ProcessID properties. Using one of the three lists as a template, try running the script before going to step 7. In the local computer, run the script, set the value of the StrComputer variable to "." (A single point in the quotation marks). 7. After running the newly created getProces.vbs script, you can verify the results of the script with the WiMi tester. In the object editor of the Win32_Process dialog box, click Instances. The resulting query result dialog lists an instance of a process running on a computer. Double-click an instance of a specified process to see the details of this instance. Back to top
Just here.
It is true that we just touched the surface layer written by the WMI script. Sincerely, this is intentional. WMI provides the possibility of such script preparation, so it is easy to cause "see the trees, no forests". But don't worry, as the content of this series, we will fill all the gaps. The important content to be refined is: WMI is a separate, most important management support technology in Windows. You do not need to be a developer or script to write authority to start writing WMI-based scripts. Continue to modify your newly created script to retrieve additional process properties, or further - retrieve other managed resources. Before we met next month, you may find that you have a toolbox full of customized system management scripts. Let us know how you do it. Listing 4: Answer for WMI tester drills
Strcomputer = "." 'Dot (.) Equals Local Computer In WMI
Set WbemServices = getObject ("WinMgmts: //" & strComputer)
SET WBEMOBJECTSET = WBEMSERVICES.INSTANCESOF ("Win32_Process")
For Each WBemObject in WbemObjectset
WScript.echo "Name:" & wbemObject.name & vbcrlf & _
"Handle:" & WbemObject.handle & vbcrlf & _
Process ID: & wbemObject.Processid
NEXT
Scripting clinic
Greg Stemp is one of the most recognized authorities in the United States, and is widely known as world-class ... haha! Well, how do you have a football coach in their resume? really? He was fired? Oh, very good! Greg Stemp works in ... Oh, come, don't I say this? Ok! Greg Stemp sells the salary from Microsoft, in Microsoft he has the title of the SYSTEM Administration Scripting Guide.
Bob Wells swayed around, and prepared to each of the people listening to him. There are rumors that Bob's two Daxie Rethers have more written to scripts than most human beings. Spatant time, Bob submitted to the System Administration Scripting Guide.
Ethan Wilansky spends many working hours in writing and consultation. He is enthusiastic on script writing, yoga, gardening and his family (not necessarily in this order). He is currently working on a method of creating scripts that can put down the garbage and washing disc.