Duration (Pacific Standard Time):
To (Pacific Standard Time):
  • None
User Action:
  • None

Using the SetEnv.bat Command Line

When you open one of the build environments, a batch file that is named SetEnv.bat runs in this window. This sets the environment variables to their default values for this environment.

In most cases, it is not necessary for you to directly start the SetEnv.bat file. However, you may find this useful when writing scripts that will execute several sequential builds.

The command-line syntax is as follows:

setenv Directory [fre|chk] [64|x64] [hal] [WIN7|WLH|WXP|WNET] [no_prefast] [bscmake] [separate_object_root][oacr|no_oacr]

setenv Directory -? 

All parameters except for no_prefast, bscmake, separate_object_root, oacr, no_oacr and Directory are case-sensitive.



Specifies the Windows Driver Kit (WDK) installation directory.


Specifies the free build environment. This can be abbreviated as f.


Specifies the checked build environment. This can be abbreviated as c.


Specifies the Itanium-based build environment.


Specifies the x64 build environment.


Specifies the HAL build environment.


Specifies the Windows 7 build environment. If no operating system is specified, this is the default value.


Specifies the Windows Vista build environment.


Specifies the Windows XP build environment.


Specifies the Windows Server 2003 build environment.


Prevents PREfast from being run during the build process. For more information, see PREFAST_ROOT.

Note   This parameter is obsolete in the WDK for Win7 and later versions of Windows operating system.


Enables the Build utility to run the BSCMake program. To run BSCMake, use the bscmake flag (or manually delete the NO_BROWSER_FILE environment variable) and include the BSCMake directory in your default path. For more information, see NO_BROWSER_FILE.


Enables BinPlace and also various build macros to be applied during the build process. The following build macros are affected by this parameter:

Note  This parameter is supported in the WDK for Windows 7 and later versions of Windows operating system.


Enables Windows Auto Code Review (OACR). If neither oacr nor no_oacr is specified, the SetEnv.bat file enables OACR by default.


Disables OACR.


Displays a short help text. You have to supply Directory for this to work, but you can use any string as a placeholder for Directory.


If you open a new Command Prompt window and run

setenv D:\ddk chk 64 WXP 

it will set up a 64-bit Windows XP checked build environment, as long as D:\ddk is indeed your WDK installation directory.

Writing Scripts

If you write a script that will automatically start the build utility, you should not run SetEnv.bat twice in the same Command Prompt window. Although SetEnv.bat will set all the environment variables needed for any given build environment, it may not delete the environment variables set by a previous use of this command.

Therefore, if you plan to run sequential builds of different types from a batch file, you should use a format along these lines:

setenv b:\ddk chk 64 WXP
setenv b:\ddk fre 64 WNET



Send comments about this topic to Microsoft

Build date: 5/3/2011