Microsoft KB Archive/250896

= How To Add or Change Environment Variables in Windows NT 4.0 Embedded =

Article ID: 250896

Article Last Modified on 6/29/2004

-

APPLIES TO


 * Microsoft Windows NT Embedded 4.0

-



This article was previously published under Q250896



IMPORTANT: This article contains information about modifying the registry. Before you modify the registry, make sure to back it up and make sure that you understand how to restore the registry if a problem occurs. For information about how to back up, restore, and edit the registry, click the following article number to view the article in the Microsoft Knowledge Base:

256986 Description of the Microsoft Windows Registry



SUMMARY
You can add or change environment variables in your Windows NT 4.0 Embedded configuration in two different ways:
 * Create a custom component with Component Designer.
 * Modify the configuration manually with Target Designer.

This article describes both methods.



MORE INFORMATION
Environment variables in Windows NT 4.0 are stored in the registry under the HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Session Manager\Environment registry key. The values under this key are entered as environment variables when you start the system. When you add or change the values under this key, you also add or change the environment variables in the target system.

IMPORTANT:For additional information on how to add or modify any registry entry in your configuration, click the article number below to view the article in the Microsoft Knowledge Base:

247824 INFO: Tips on How to Create Components for Microsoft Windows NT 4.0 Embedded

I. Create a Custom Component with Component Designer
You can use this method to add an environment variable or change an existing one. You can either create registry entries manually or move them from the registry of the development machine using a drag-and-drop operation.

Add a New Environment Variable by Creating a Component Manually
WARNING: If you use Registry Editor incorrectly, you may cause serious problems that may require you to reinstall your operating system. Microsoft cannot guarantee that you can solve problems that result from using Registry Editor incorrectly. Use Registry Editor at your own risk.

If the environment variable does not exist on your development machine, you must manually create the registry entry by following these steps:  Start Component Designer and create a new component. Select the registry section of your new component. Right-click Registry View, and select Add Registry Key. In the Key Path drop-down list box, select HKEY_LOCAL_MACHINE\SYSTEM. In the Key Name edit box, type the following:

ControlSet001\Control\Session Manager\Environment

 Click OK. The registry key should appear in the Registry View pane. Right-click the new key, and select Add Registry Value from the context menu.</li> In the Value Name edit box, type the name of the environment variable that you want to add.</li> In the Data type drop-down list box, select the data type of the new registry value. Click OK.

For more information on registry value data types, see the "registry, entries, adding" topic in the Windows NT 4.0 Embedded Help file.</li> An editor dialog box specific to the data type that you specified appears. Enter the value for your new environment variable, and then click OK.</li> Repeat steps 2-9 for each environment variable that you want to create.</li></ol>

Once you create the component, save the component and use the following steps to add it to your configuration:
 * 1) Open Target Designer.
 * 2) From the Tools menu, click Component Management.
 * 3) In the Component Management dialog box, click Add.
 * 4) Select the newly created component. Click Open. Target Designer then processes the component and displays a summary. Click OK.
 * 5) Click OK to close the Component Management dialog box.
 * 6) Find the capability where you stored your component in the tree view of Target Designer.
 * 7) Right-click the newly created component in the tree view. From the context menu, click Add.
 * 8) Check dependencies and rebuild. You can now redeploy your new target image.

You can verify that the environment variable exists by following these steps: <ol> Select the configuration in the tree view.</li> Click View Registry.</li> Locate the following registry key in the registry view:

HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Session Manager\Environment

</li></ol>

Add an Environment Variable with Drag-and-drop Method
If the environment variable exists on your development machine, you can move the registry entries using the drag-and-drop method as follows:
 * 1) Select the Registry section of your new component. Right-click Registry View, and then click Drag from Local Registry. A Registry Editor window opens.
 * 2) In the tree view of the Registry Editor, find the registry key HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Session Manager\Environment.
 * 3) In the data view of the Registry Editor, select the environment variable that you want to add or modify, and then drag it to the Component Designer window. This adds the registry key and value to the component.
 * 4) Repeat step 3 until you have added all required environment variables to the custom component.
 * 5) Close the Registry Editor window.NOTE: You can also drag the entire Environment registry key to the component to add all the environment variables on the development machine to the component.

II. Modify the Configuration Manually with Target Designer
You can also manually add or modify environment variables directly in Target Designer without using a custom component. Note that registry changes done in Target Designer are specific to the configuration in which they are changed, so you must change each configuration that you want to update.

Manually Add a New Environment Variable to an Existing Configuration
Follow these steps to add a new environment variable to an existing configuration:
 * 1) In the configuration tree view, select the configuration that you want to modify.
 * 2) From the View menu, click Registry.
 * 3) In the registry view, select the registry key HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Session Manager\Environment.
 * 4) Right-click the Environment key, and then click Add Value.
 * 5) In the Value name edit field, type the name of the environment variable that you want to add.
 * 6) In the Data type combo box, select the data type of the environment that you want to add, and then click OK.

For more information on registry value data types, see the "registry, entries, adding" topic in the Windows NT 4.0 Embedded Help file.
 * 1) In the Edit dialog box, type the value for the environment variable. Click OK.

Note that the icon for the new key changes appearance and color to indicate that you added it manually.
 * 1) Repeat steps 4-7 for each environment variable that you want to add.
 * 2) Check dependencies, and rebuild. You can now redeploy your new target image.

Manually Change an Existing Environment Variable
Follow these steps to change an existing environment variable in a specific configuration:
 * 1) In the configuration tree view, select the configuration that you want to modify.
 * 2) From View menu, click Registry.
 * 3) In the registry view, select the registry key HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Session Manager\Environment.
 * 4) Click the environment variable that you want to change under the Environment key.
 * 5) In the Edit dialog box, type the new value, and then click OK.

Note that the icon for the key that you select changes to indicate that data has changed.
 * 1) Repeat steps 1-5 for each environment variable that you want to modify.
 * 2) Check dependencies, and rebuild. You can now redeploy your new target image.

Keywords: kbhowto KB250896

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.