Error spawning 'cmd.exe' from VS 2005 pro, c++

Posted on 2006-06-04
Last Modified: 2012-05-05
For a while I have been programming with VS 2005 pro with C#, the complier works okay.

I move on into C++ to experiment with class and interface, I started off with simple hello world application. I created new project (via tutorial webpage) and use C++.

//=================================== main.cpp.
#include "stdafx.h"
#undef MessageBox
// Define our entry-point
int __stdcall WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
                                LPSTR lpStrCmdString, int nCmdShow)
      // Display a managed message-box
      System::Windows::Forms::MessageBox::Show("Hello C++/CLI", "TestApp", System::Windows::Forms::MessageBoxButtons::OK);

      return 0;
//=================================== header file (stdafx.h)
// Common include file for Windows Platform SDK

#pragma once

// Minimum requirements
#define WINVER                  0x0400      // Top-level Windows version, common for both Windows 95/98/Me and NT-family
#define _WIN32_WINNT      0x0400      // Windows NT 4.0
#define _WIN32_WINDOWS      0x0410  // Windows 98
#define _WIN32_IE            0x0400      // Internet Explorer 4.0

#define WIN32_LEAN_AND_MEAN            // Exclude rarely-used stuff from Windows headers

// Windows Header Files:
#include <windows.h>
//=====================================Error message during debug

During debug process, it came up with error:-

Error spawning 'cmd.exe'


Build Log
Build started: Project: Hello_CLI, Configuration: Debug|Win32
Command Lines
Creating temporary file "c:\VS2005\CPlusPlus\Hello_CLI\Hello_CLI\Debug\RSP00000330564928.rsp" with contents
/outputresource:"..\debug\Hello_CLI.exe;#1" /manifest
Creating command line "mt.exe @c:\VS2005\CPlusPlus\Hello_CLI\Hello_CLI\Debug\RSP00000330564928.rsp /nologo"
Creating temporary file "c:\VS2005\CPlusPlus\Hello_CLI\Hello_CLI\Debug\BAT00000430564928.bat" with contents
@echo Manifest resource last updated at %TIME% on %DATE% > .\Debug\mt.dep
Creating command line "c:\VS2005\CPlusPlus\Hello_CLI\Hello_CLI\Debug\BAT00000430564928.bat"
Output Window
Embedding manifest...
Project : error PRJ0003 : Error spawning 'cmd.exe'.
Build log was saved at "file://c:\VS2005\CPlusPlus\Hello_CLI\Hello_CLI\Debug\BuildLog.htm"
Hello_CLI - 1 error(s), 0 warning(s)

Now I investigated on internet and could make sense out of it. No lucks

I tried other program and it come with similar error...C++ is not working at all(!).

Question by:riscy
    LVL 37

    Expert Comment

    by:Harisha M G
    From Microsoft site:

    Setting the environment PATH variable in the control panel to the same value as the one echo %path% produces in the visual studio shell fixes this issue.

    So, you need to change the path !!

    Author Comment

    Please extend this...I not sure I understand this..

    Author Comment

    On source suggest to do this and it seem to cure the problem but not sure if this is right solution

    Project -> "Your project" Properties -> Configuration Properties-> Manifest Tool ->Input and Output -> Embed Manifest = No
    The manifest file will be creating.

    Please anyone explain to me what happen and why this fix this

    LVL 37

    Expert Comment

    by:Harisha M G
    Goto Start --> Programs --> Microsoft Visual Studio .. -> Tools --> Visual Studio Command Prompt

    Type "path > C:\path.txt" at the command prompt, and then "exit"

    Goto Start --> Run and type "cmd.exe"

    Type "path < C:\path.txt", and then "exit"

    Author Comment

    I followed the procedure and it came out

    C:\Documents and Settings\Riscy>path<c:\path.txt
    PATH=C:\MCC18\mpasm;C:\MCC18\bin;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\Program Files\Common Files\Roxio Shared\DLLShared\;C:\VXIPNP\WINNT\BIN;C:\Program Files\ZipGenius 6\;C:\Program Files\Microsoft SQL Server\90\Tools\binn\;C:\Program Files\Common Files\Adobe\AGL;C:\MCC18\mpasm;C:\MCC18\bin;C\WINDOWS\Microsoft.NET\Framework\v1.1.4322

    I then tried again...error still there.

    LVL 37

    Accepted Solution

    OK.. try this:

    open C:\path.txt in notepad

    Copy everything.

    Press Winkey (That exists between Ctrl and Alt) + Pause

    Goto Advanced, Environment Variables

    Select PATH and click Edit put the copied text, click OK. Do the same for the other list box too.

    Author Comment

    Okay that fix it...thanks
    Would be useful for full explanition or reference material relating to this problem if you have any
    The award is your.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Find Ransomware Secrets With All-Source Analysis

    Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

    Suggested Solutions

    This article will show, step by step, how to integrate R code into a R Sweave document
    A short article about a problem I had getting the GPS LocationListener working.
    An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now