Microsoft KB Archive/276593

= You receive a &quot;NMAKE : fatal error U1045: spawn failed : Invalid argument&quot; error message when you compile a makefile by using the Microsoft Program Maintenance utility =

Article ID: 276593

Article Last Modified on 12/29/2005

-

APPLIES TO


 * Microsoft Visual C++ 5.0 Enterprise Edition
 * Microsoft Visual C++ 6.0 Enterprise Edition
 * Microsoft Visual C++ 5.0 Professional Edition
 * Microsoft Visual C++ 6.0 Professional Edition
 * Microsoft Visual C++ 6.0 Standard Edition
 * Microsoft Visual C++ .NET 2002 Standard Edition
 * Microsoft Visual C++ .NET 2003 Standard Edition
 * Microsoft Visual C++ 2005 Express Edition

-



This article was previously published under Q276593



Note Microsoft Visual C++ .NET (2002) supports both the managed code model that is provided by the Microsoft .NET Framework and the unmanaged native Microsoft Windows code model. The information in this article applies only to unmanaged Visual C++ code.

Note Microsoft Visual C++ 2005 supports both the managed code model that is provided by the Microsoft .NET Framework and the unmanaged native Microsoft Windows code model.



SYMPTOMS
When you compile a makefile by using the Microsoft Program Maintenance utility, Nmake.exe (NMAKE), you may receive the following error message:

NMAKE : fatal error U1045: spawn failed : Invalid argument



CAUSE
NMAKE uses the command interpreter to spawn the different tools that are needed to build the targets. The path to the command interpreter is found by querying for the value of the ComSpec environment variable. If the ComSpec environment variable is set incorrectly, you receive the error message shown in the &quot;Symptoms&quot; section.



RESOLUTION
To resolve this problem, ensure that the ComSpec environment variable is set correctly.

For Microsoft Windows NT and Microsoft Windows 2000, the command interpreter is Cmd.exe. The ComSpec environment variable should contain the following:

%SYSTEMROOT%\System32\Cmd.exe

To view and modify the ComSpec environment variable in Windows NT:
 * 1) Open Control Panel.
 * 2) Double-click the System icon, and then click the Environment tab.
 * 3) Select the ComSpec variable, which is located in the System Variables box.
 * 4) Modify the variable by using the Value edit box.

To view and modify the ComSpec environment variable in Microsoft Windows Server 2003, in Windows 2000, and in Windows XP, follow these steps:
 * 1) Open Control Panel.
 * 2) Double-click the System icon, click the Advanced tab, and then click Environment Variables.
 * 3) Select the ComSpec variable, which is located in the System Variables box.
 * 4) Click Edit to modify the variable.

For Microsoft Windows 95, Microsoft Windows 98, and Microsoft Windows Millennium (Me), the command interpreter is Command.com. The ComSpec environment variable should contain the following:

%WINDIR%\Command.com

To view the value of the ComSpec environment variable:
 * 1) Start the command interpreter. Click Start, point to Programs, and then click MS-DOS Prompt.
 * 2) At the command prompt, type set, and then press ENTER.

A list of all of the environment variables should be displayed in alphabetical order.

To correctly set the ComSpec environment variable:  Open the Autoexec.bat file and add the following line:

set ComSpec=%WINDIR%\Command.com

 Save the Autoexec.bat file and restart the computer.

NOTE: On all these operating systems, ComSpec must not contain multiple paths. Only a single path is acceptable.



Steps to reproduce the behavior in Windows 2000
 Start the command interpreter. Click Start, point to Programs, point to Accessories, and then click Command Prompt. Type the following at the command prompt, and then press ENTER:

set ComSpec=%ComSpec%;%ComSpec%

</li> Run NMAKE on your make file.</li></ol>

Keywords: kberrmsg kbtshoot kbprb KB276593

-

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

© Microsoft Corporation. All rights reserved.