2.4. Installing or Uninstalling a Windows Component

Problem

You want to install or uninstall a Windows Component.

Solution

Using a graphical user interface

  1. From the Control Panel , open the Add or Remove Programs applet.

  2. Click on Add/Remove Windows Components.

  3. Click on the component you are interested in.

  4. If there are subcomponents, the Details button will become active. Click on it. Check the box beside the components you want to install. When you are done, click OK.

  5. Click Next. At this point the component(s) will be installed.

  6. Click Finish to close the screen.

Using a command-line interface

Create an answer file using a text editor, such as notepad.exe. Here is an example answer file that would install the DNS Server service:

[netoptionalcomponents]
dns=1

See the Discussion section for more on answer files.

Next, run the sysocmgr utility with following parameters (assuming you named the answer file c:\comp_install.txt):

> sysocmgr /i:%windir%\inf\sysoc.inf /u:c:\comp_install.txt

Tip

The sysocmgr utility has additional options for suppressing dialog boxes (/x and /q). For the complete list of sysocmgr options, run sysocmgr /? from a command line.

Using VBScript

Unfortunately, there are no scripting interfaces for installing Windows Components. However, you can run the sysocmgr command from the previous section directly within a batch script (.bat extension) or using the WScript.Shell Run method within VBScript.

' This code simulates the same steps from the command-line solution. ' First, an ...

Get Windows Server Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.