You are here:   Home Tips & Tricks Install Windows Components from Command Line
Jul
09
2007

Install Windows Components from Command Line

E-mail
Written by Misha Hanin   

Windows XP and Windows Server 2000 / 2003 have a built-in utility called the System Atand-Alone Optional Component Manager (sysocmgr.exe) to programmatically add or remove Windows components. Running sysocmgr.exe with no parameters will display the usage information. The most basic command line will look like this:

%windir%\system32\sysocmgr.exe /i:%windir%\inf\sysoc.inf 

This parameter - (/i:) - is mandatory and specifies the location of the master .inf file (%windir%\inf\sysoc.inf). Executing this command will simply run the Windows Components Wizard. As you can see, the above command can be used as a shortcut to the Windows Components Wizard.

The real power of sysocmgr is its unattended mode. Additional parameters control user interface, handle restarting, and define which components are added or removed. These parameters can be proveded to the utility in a form of the standard Windows unattended answer file. Sysocmgr will only look for the [Components] and [NetOptionalComponents] sections in the answer file, so this file can be specifically designed for the component management or even reused from a Windows unattended installation. Some components have their own unattended answer file sections, which are also parsed.


Examples

The following example uses an answer file (/u:) named ocm.txt in the temporary directory (%temp%\ocm.txt), suppresses any necessary restart (/r), and displays no user interface (/q):

%windir%\system32\sysocmgr.exe /i:%windir%\inf\sysoc.inf /u:%temp%\ocm.txt /r /q

Another example answer file adds the Simple Network Management Protocol (SNMP) service and configures the agent settings:


[NetOptionalComponents]

SNMP = 1



[SNMP]

Contact_Name = Michael Khanin

Location = Canada



Service = Physical, Applications, End-to-End



Community_Name = Public

Traps = server1.thesystemadministrator.com, server2.thesystemadministrator.com



Send_Authentication = Yes

Accept_CommunityName = Public:Read_Only

Any_Host = No

Limit_Host = server1.thesystemadministrator.com, server2.thesystemadministrator.com 

Usage tips


  • Sysocmgr can only be run by users with local administrative rights. It can be combined with runas:


 runas /user:admin "%windir%\system32\sysocmgr.exe /i:%windir%\inf\sysoc.inf"

  • Make sure that the target system has the Windows installation source available. The following registry values must point to a source to which the administrative user has access (in case of a network path, a local administrator account may not be able to access it):


 [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Setup] "SourcePath"="c:\\windows\\i386" "Installation Sources"= … (REG_MULTI_SZ value) [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion] "SourcePath"="c:\\windows\\i386"




Install Windows Components from Command LineWant to learn more Windows tools, tricks and tips? Check out this amazing ebook!