Previous Page
Next Page

One Step Further: Compiling MOF files

In this section, we will use MofComp.exe to compile MOF files into the WBEM repository. We will first create a new namespace using MofComp.exe and a MOF file. We will then delete that namespace by using MofComp.exe and a MOF file. Next, we will create an instance of the ActiveScriptEventConsumer class. Following that, we will delete the instance of the active script consumer we create.

1.
Copy the four MOF files in the \My Documents\Microsoft Press\VBScriptSBS\ch21\OneStepFurther folder to a directory you can easily access from a command prompt.

2.
Open a command prompt.

3.
At the command prompt, use MofComp to compile Createnamespace.mof. This will create a new namespace in WMI off the root namespace that is called Mynamespace. The syntax of the command will look something like the following:

C:\FSO>mofcomp createnamespace.mof

The output from this command will look like the following:

Microsoft (R) 32-bit MOF Compiler Version 5.1.2600.2180
Copyright (c) Microsoft Corp. 1997-2001. All rights reserved.
Parsing MOF file: createnamespace.mof
MOF file has been successfully parsed
Storing data in the repository...
Done!

4.
Run the \My Documents\Microsoft Press\VBScriptSBS\ch21\OneStepFurther\ListWMINamespace.vbs script to confirm the namespace was created.

5.
Now we want to delete the namespace. At the command prompt, use MofComp to compile Deletenamespace.mof. The command will look like the following:

C:\FSO>mofcomp deletenamespace.mof

The output from the command will look like the following:

Microsoft (R) 32-bit MOF Compiler Version 5.1.2600.2180
Copyright (c) Microsoft Corp. 1997-2001. All rights reserved.
Parsing MOF file: deletenamespace.mof
MOF file has been successfully parsed
Storing data in the repository...
Done!

6.
Now we want to create a new instance of the ActiveScriptEventConsumer class. We have a MOF file that will write to an event log when Calc.exe is closed out. It will require a reboot to take effect.

7.
At the command prompt, use MofComp to compile the Asec.mof MOF file. This MOF file will take about a minute to compile, so do not get alarmed when it does not compile as quickly as the two previous files did. The command to do this will look like the following:

C:\FSO>mofcomp asec.mof

When it is completed compiling, the output will look like the following:

Microsoft (R) 32-bit MOF Compiler Version 5.1.2600.2180
Copyright (c) Microsoft Corp. 1997-2001. All rights reserved.
Parsing MOF file: asec.mof
MOF file has been successfully parsed
Storing data in the repository...
Done!

8.
Reboot your computer and launch Calc.exe. Use it for a minute or so and perform some calculations with it. Exit the calculator.

9.
Navigate to your C drive, where you should see a text file called Asec.log. Delete the log file. If you do not see a log file there within 5 to 10 seconds, then check the Windows Application event log for errors.

10.
The last thing we need to do is to delete the instance of the active script event consumer. To do this, we will compile the DeleteAsec.mof file using MofComp. The command to do this will look like the following:

C:FSO\>mofcomp deleteasec.mof

If the delete is successful, you will see an output similar to the following:

Microsoft (R) 32-bit MOF Compiler Version 5.1.2600.2180
Copyright (c) Microsoft Corp. 1997-2001. All rights reserved.
Parsing MOF file: deleteasec.mof
MOF file has been successfully parsed
Storing data in the repository...
Done!

Chapter 21 Quick Reference

To

Do This

Determine if WMI service is accepting new connections

Use WBEM Test

Test the scripting interface of WMI service

Use the Scriptomatic

Quickly diagnose the health of the WMI service

Open the WMI control tool

See if the WMI service is running

Use the Services tool



Previous Page
Next Page