When trying to build a C++ project with Visual Studio 2005 Beta 2(or 2007, 2008), I always get a PRJ0003 error:Error spawning 'cmd.exe'
Since I mostly use C# this hasn't been bothering me unduly, particularly since it mainly seems to afflict a custom build action that doesn't appear to be essential for the compilation process... But I finally got around to finding a solution.
The first clue was that if I invoked VCBuild.exe from the command line, I could get rid of the problem by using the /useenv command line option. This tells it to use environment variables to get the path to libraries, executable and the like instead of using the configured directories. The fact that it works when using the environment variables, but not when using the configured directories pointed the finger at the configured directories...
This config can be found in Visual Studio's Options dialog (off the Tools menu). It's in the Projects and Solutions -> VC++ Directories page. This turns out to configure settings used both by VS and also by the command-line VCBuild. (I think VS just launches VCBuild to build your project.)
This options page has a row of buttons on the right hand side. One of these is a tick. Clicking that checks all of the configured items for validity. When I clicked this, it complained about three items:%SystemRoot%\System32
%SystemRoot%
%SystemRoot%\System32\wbem
Those entries look out of place. They're using the %xxx% variable syntax you can use from the command line. But all the other entries use the $(xxx) convention. So I changed the entries to:$(SystemRoot)\System32
$(SystemRoot)
$(SystemRoot)\System32\wbem
I clicked the tick button again, and this time it was happy. And now when I build C++ projects (either from the command line or VS) I no longer get the Error spawning 'cmd.exe' error.
Since I mostly use C# this hasn't been bothering me unduly, particularly since it mainly seems to afflict a custom build action that doesn't appear to be essential for the compilation process... But I finally got around to finding a solution.
The first clue was that if I invoked VCBuild.exe from the command line, I could get rid of the problem by using the /useenv command line option. This tells it to use environment variables to get the path to libraries, executable and the like instead of using the configured directories. The fact that it works when using the environment variables, but not when using the configured directories pointed the finger at the configured directories...
This config can be found in Visual Studio's Options dialog (off the Tools menu). It's in the Projects and Solutions -> VC++ Directories page. This turns out to configure settings used both by VS and also by the command-line VCBuild. (I think VS just launches VCBuild to build your project.)
This options page has a row of buttons on the right hand side. One of these is a tick. Clicking that checks all of the configured items for validity. When I clicked this, it complained about three items:%SystemRoot%\System32
%SystemRoot%
%SystemRoot%\System32\wbem
Those entries look out of place. They're using the %xxx% variable syntax you can use from the command line. But all the other entries use the $(xxx) convention. So I changed the entries to:$(SystemRoot)\System32
$(SystemRoot)
$(SystemRoot)\System32\wbem
I clicked the tick button again, and this time it was happy. And now when I build C++ projects (either from the command line or VS) I no longer get the Error spawning 'cmd.exe' error.
댓글