error PRJ0002 : 错误的结果 3 (从“C:\Windows\system32\cmd.exe”返回) WinDDK

时间:2022-09-02 15:55:37

根据标题提示的错误,第一念头就是把错误代码放在网上去搜索答案。前期没有搜索到答案,自己琢磨了一会后,重新定义关键词终于寻得答案,参考网址我记不到了,大概的结局思路为:

错误代码如下:

OSR DDKBUILD.CMD V7.4/r60 (2009-11-28) - OSR, Open Systems Resources, Inc.
DDKBLD: ERROR #3: To build using type W7 you need to set the %W7BASE% environment variable to point to the Windows 7/Windows 2008 Server R2 DDK base directory!
USAGE:
======
ddkbuild [flags] [-WDF] [-PREFAST] [-CUV]
Values for :
---------------------------------------------------------------------------
Target OS version and architecture | Miscellaneous
-------------------------------------|-------------------------------------
| Windows | CPU | Base directory | alias(es)
-------------|-------------|---------|----------------|--------------------
-NT4 | NT 4.0 | x86 | %NT4BASE% |
-W2K | 2000 | x86 | %W2KBASE% |
-W2K64 | 2000 | Itanium | %W2KBASE% | -W2KI64
-WXP | XP | x86 | %WXPBASE% | -XP
-WXP64 | XP | Itanium | %WXPBASE% | -WXPI64, -XP64
-WXP2K | 2000 | x86 | %WXPBASE% | -XPW2K
-WNET | 2003 | x86 | %WNETBASE% |
-WNET64 | 2003 | Itanium | %WNETBASE% | -WNETI64
-WNETXP | XP | x86 | %WNETBASE% |
-WNETXP64 | XP | Itanium | %WNETBASE% |
-WNETAMD64 | 2003/XP x64 | x64 | %WNETBASE% | -WNETX64, -WNETA64
-WNET2K | 2000 SP3 | x86 | %WNETBASE% | -WNETW2K
-WLH | Vista/2008 | x86 | %WLHBASE% |
-WLH2K | 2000 SP4 | x86 | %WLHBASE% |
-WLHXP | XP | x86 | %WLHBASE% |
-WLHXP64 | XP | Itanium | %WLHBASE% |
-WLHNET | 2003 | x86 | %WLHBASE% |
-WLHNETI64 | 2003 | Itanium | %WLHBASE% | -WLHNET64
-WLHNETX64 | 2003/XP x64 | x64 | %WLHBASE% | -WLHNETA64
-WLHI64 | Vista/2008 | Itanium | %WLHBASE% | -WLH64
-WLHX64 | Vista/2008 | x64 | %WLHBASE% | -WLHA64
-W7 | 7/2008 R2 | x86 | %W7BASE% | -WIN7
-W7I64 | 7/2008 R2 | Itanium | %W7BASE% | -WIN764
-W7X64 | 7/2008 R2 | x64 | %W7BASE% | -WIN7A64
-W7LH | Vista/2008 | x86 | %W7BASE% | -WIN7WLH
-W7LHI64 | Vista/2008 | Itanium | %W7BASE% | -WIN7WLH64
-W7LHX64 | Vista/2008 | x64 | %W7BASE% | -WIN7WLHA64
-W7NET | 2003 | x86 | %W7BASE% | -WIN7NET
-W7NETI64 | 2003 | Itanium | %W7BASE% | -WIN7NET64
-W7NETX64 | 2003/XP x64 | x64 | %W7BASE% | -WIN7NETA64
-W7XP | XP | x86 | %W7BASE% | -WIN7XP
---------------------------------------------------------------------------
Support for NT4 and W2K DDKs is deprecated and not checked anymore
in new versions. It may or may not work properly.
---------------------------------------------------------------------------
Values for :
checked, chk indicates a checked build
free, fre indicates a free build
Remaining parameters (all optional):
path to build directory, try . (current directory)
[flags] any flags you think should be passed to build (try /a
for clean)
-WDF performs a WDF build
-PREFAST performs a PREFAST build
-CUV uses the Call Usage Verifier, implies a PREFAST build
Special files:
The build target directory (where the DIRS or SOURCES file resides) can
contain the following files:
- ddkprebld.cmd
Allows to include a step before the BUILD tool from the DDK is called
but after the environment for the respective DDK has been set!
- ddkpostbld.cmd
Allows to include a step after the BUILD tool from the DDK is called,
so the environment is still available to the script.
- ddkbldenv.cmd
Allows to set (or override) _any_ environment variables that may exist
in the global environment. Thus you can set the base directory for the
DDK from inside this script, making your project more self-contained.
DDKBUILD will only handle those files which exist, so you may choose to
use none, one or multiple of these script files.
(All scripts execute inside their current directory. Consider this!)
Examples:
"ddkbuild -NT4 checked ." (for NT4 BUILD)
"ddkbuild -WXP64 chk ."
"ddkbuild -WXP chk c:\projects\myproject"
"ddkbuild -WNET64 chk ." (IA64 build)
"ddkbuild -WNETAMD64 chk ." (AMD64/EM64T build)
"ddkbuild -WNETXP chk . -cZ -WDF"
"ddkbuild -WNETXP chk . -cZ -PREFAST"
In order for this procedure to work correctly for each platform, it
requires an environment variable to be set up for certain platforms.
There is an auto-detection mechanism in this script, which will work best
if the DDK/WDK was installed using the normal installer (i.e. not just
copied). The auto-detection is based on the DDK/WDK for which you request
a build. Whenever you set the variable explicitly, this will take
precedence over the auto-detected path!
The environment variables are as follows:
%NT4BASE% - Set this up for "-NT4" builds
%W2KBASE% - Set this up for "-W2K" and "-W2K64" builds
%WXPBASE% - Set this up for "-WXP", "-WXP64", "-WXP2K" builds
%WNETBASE% - Set this up for "-WNET*" builds
%WLHBASE% - Set this up for "-WLH*" builds
%W7BASE% - Set this up for "-W7*" builds
%WDF_ROOT% must be set if attempting to do a WDF Build previous to the
Vista WDK (in later DDKs there is no need to set WDF_ROOT).
Path to this script:
C:\WinDDK\ddkbuild.cmd
OSR DDKBUILD.CMD V7.4/r60 (2009-11-28) - OSR, Open Systems Resources, Inc.
-> report any problems to or
项目 : error PRJ0002 : 错误的结果 3 (从“C:\Windows\system32\cmd.exe”返回)。

错误代码地方如上方红色标记的地方。由

DDKBLD: ERROR #3: To build using type W7 you need to set the %W7BASE% environment variable to point to the Windows 7/Windows 2008 Server R2 DDK base directory!

可以判定是配置路径的问题,但通过在环境变量里查看环境变量是没有问题的。重新锁定错误地方,这次锁定到上面的绿色标记处:

DDKBUILD.CMD
初步判断是这个文件出问题了,在WinDDK中打开这个文件,关键字搜索W7BASE,定位到下面这段代码:

set BASEDIROS=Windows 7/Windows 2008 Server R2
set BASEDIRVAR=W7BASE
:: The default for OACR is off ("no_oacr" appended)
if not DEFINED SETTING_OACR set SETTING_OACR=no_oacr
:: The default for "separate_object_root" is to not pass it to setenv.bat
if not DEFINED SETTING_SEP_OBJ_ROOT set SETTING_SEPARATE_OBJ_ROOT=
:: Other flavor of DDKBUILD
if not DEFINED W7BASE if DEFINED WIN7BASE set BASEDIRVAR=WIN7BASE
:: Compatibility between BUILD and VS ... prevent pipes from being used
%OSR_ECHO% Clearing %%VS_UNICODE_OUTPUT%% ...
set VS_UNICODE_OUTPUT=
:: Return to caller if the BASEDIR is already defined (either customized or global)
if DEFINED %BASEDIRVAR% goto :CommonCheckNoErrorWithReturn
call :DetectBaseDirTemp "7600.16385.0"
if DEFINED BASEDIRTEMP if exist "%BASEDIRTEMP%" goto :CommonCheckSetVarWithReturn
goto :CommonCheckErrorNotSupportedWithReturn

最后发现是DetectBaseDirTemp "7600.16385.0"与自己安装的WinDDK版本不一致,我的电脑是7600.16385.1,修改之问题解决。