none
Command Prompt error- 'C:\windows\system32\command.bat is not recognized as an internal or external command

    Question

  • I am relatively new at Visual Studios, and I am trying to get it to work on my vista. My command prompt displays the message

     "'C:\Windows\system32\command.bat' is not recognized as an internal or external command, operable program or batch file." 

    I checked to see if the application and target were still there, but I am just not sure why it would do this whenever I would run it. When I type path into command prompt it says

    PATH=C:\Program Files\Common Files\Microsoft Shared\Windows Live;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Program Files\QuickTime\QTSystem\;C:\Program Files\Microsoft SQL Server\90\Tools\binn\;C:\Program Files\Common Files\Microsoft Shared\Windows Live

    I have command.exe, but I am not sure if the path is corrupted else must be corrupted or something.

    I am not sure how to change the environment variable for command prompt.

     Is there any way I can reinstall command prompt without messing up the rest of my computer?

    Any help on this would be greatly appreciated.

    Saturday, November 07, 2009 12:44 AM

Answers

  • Two things of note in your last post (if accurate) which were not
    obvious from your prior posts:

    (1) The message does not appear when you open the 16-bit shell (command.com)

    (2) When you open the 32-bit shell (cmd.exe) the message appears *after*
    the shell opens, not before.

    Quote>If a file command.bat does not exist, is there a way I can reconfigure
    Quote>the way command prompt starts in Windows or do I need to reinstall
    Quote>Windows to make command prompt work without the command.bat file?

    As I don't have Vista installed, I'm averse to making suggestions re
    configuring that OS version.

    I don't know why you're obsessing about this. It's an informational message
    only. The command prompts are working. If you want to go to all the trouble
    of reinstalling Windows and all of your software, just to eliminate an
    innocuous message, it's your dime/time. If it were happening on my PC and
    I couldn't track down the source, I would give it what it wants. Create a
    simple command.bat file in C:\windows\system32 such as:

    @echo off
    rem Dummy file to appease Windows and let me sleep at night


    The message should go away when you open a command prompt.

    As previously noted by Sheng Jiang, this has nothing to do with Visual C++
    and therefore is off-topic in this forum. If you need to pursue it further,
    I suggest you find a Vista support forum or newsgroup.

    - Wayne
    • Marked as answer by tobymacfan Tuesday, November 10, 2009 7:17 AM
    Tuesday, November 10, 2009 3:10 AM

All replies

  • It is not clear from your post whether you're doing this through a program or manually.

    Also please state when this error is shown.
    I mean what action caused this error.

    «_Superman_»
    Microsoft MVP (Visual C++)
    Saturday, November 07, 2009 1:03 AM
  • Quote>displays the message:
     "'C:\Windows\system32\command.bat' is not recognized"
     
    Quote>I have command.exe, but I am not sure if the path is corrupted
    Quote>else must be corrupted or something.

    Looks like your grammar is corrupted, or at least fractured. ;-)

    Where did you see command.exe?

    AFAIK, neither command.bat nor command.exe are part of a normal Windows
    installation.

    I don't know what they use in Vista, but under XP and prior it has always
    been command.com (not .exe) and is in the c:\windows\system32 directory.
    Also, command.com is a 16-bit legacy shell - Win32 releases since at least
    NT have used the cmd.exe shell.

    - Wayne
    Saturday, November 07, 2009 1:42 AM
  • Lol. Sorry, I guess my grammar is also messed up.

    My command.exe has the target
    %SystemRoot%\system32\cmd.exe

    and it is in the Windows\System32 folder.
    Saturday, November 07, 2009 2:21 AM
  • I give up. Did changing to "cmd.exe" solve the problem?
    Saturday, November 07, 2009 3:04 AM
  • No. I am not really sure what my command prompt is using as a source file for command.bat. I ran a search, but I could not find any file command.bat, but I can find some command.com Jscript files.
    Saturday, November 07, 2009 6:44 AM
  • where this bat file is referenced? It is not referenced in Microsoft software so others cannot reproduce your problem on their computers. If you can not help others to reproduce the problem outside your computer, you need find someone willing to examine your computer.

    The following is signature, not part of post
    Please mark the post answered your question as the answer, and mark other helpful posts as helpful.
    Visual C++ MVP
    Saturday, November 07, 2009 2:14 PM
  • I am sorry. I am not sure when exactly this problem occurred on my computer, but it is affecting command prompt every time I open it by displaying the message
     
    'C:\Windows\System32\command.bat' is not recognized as an internal or external command, operable program, or batch file.

     I cannot find anywhere the command.bat file it is referenced either, but I guess my computer is trying to run this file once command prompt opens. But when I checked to see where it was on my computer, I couldn't find a command.bat on there either. Command prompt is going to the right location to open in my computer, but I am guessing it is referencing the wrong file once it opens or something. I am not sure if my computer needs this command.bat file to operate command prompt, or if it needs a different file and I am not sure how to change the file command prompt uses once it opens?

    Thank you very much for your help.
    Saturday, November 07, 2009 4:35 PM
  • Talk to your company's IT department. This question has nothing to do with Visual C++ and it looks like you are unable to give steps to reproduce this problem.

    The following is signature, not part of post
    Please mark the post answered your question as the answer, and mark other helpful posts as helpful.
    Visual C++ MVP
    Saturday, November 07, 2009 4:51 PM
  • tobymacfan -

    You need to articulate your problem much more clearly. You are using too
    general a description for anyone to clearly understand what you are doing.

    Quote>I am relatively new at Visual Studios, and I am trying to get it to work
    Quote>on my vista.

    Back up a bit, and tell us how far you have gotten with installing VS and
    which version you are installing. Can you open the VS IDE?

    Quote>it is affecting command prompt every time I open it

    Every time you open WHAT? The command prompt or VS?

    First, clarify *how* you are trying to open the command prompt window.

    Are you trying to do it from inside the VS IDE?
    For example, by clicking on the menu item:

    Tools->Visual Studio 2008 Command Prompt

    Or are you trying to start it some other way?

    See if you can open a console window this way:

    Click on the Start menu on the Windows task bar.
    Click on "Run".
    In the dialog that opens type in cmd and then click on OK.

    A console window should open.

    Display your environment variables by typing in this:

    set | more

    Look down the list for the comspec variable and tell us what it says.
    It should look like this (assuming Vista hasn't changed):

    ComSpec=C:\WINDOWS\system32\cmd.exe

    *Copy* from the screen the comspec line and *paste* it into a post here.
    Do NOT type it in manually. Use the Windows clipboard to show *exactly*
    what is there.

    - Wayne
    Saturday, November 07, 2009 6:34 PM
  • Okay. I am sorry, I will try to better explain the problem I am having. I have bolded the text that it displays in command prompt.

    I installed Visual Studios 2008 and the program works. I can run it and open the VS IDE.

    When I create a project and try to execute the code the program compiles and tells me there are build errors.
    If I click to continue it runs the programs but displays the message


    'C:\Windows\system32\command.bat' is not recognized as an internal or external c
    ommand,
    operable program or batch file.
    Press any key to continue . . .

    in the command prompt window.

    I then opened command prompt from the start menu and it displays the message

    'C:\Windows\system32\command.bat' is not recognized as an internal or external c
    ommand,
    operable program or batch file.
    Press any key to continue . . .

    When I click on "run" from the start menu, it does not allow me to copy and paste the text, but it displays the message

    Specified COMMAND search directory bad
    Microsoft (R) Windows DOS
    (C)Copyright Microsoft Corp 1990-2001

    C>

    When I type set|more after clicking on "run" it displays the message

    Bad command or file name

    However, when I open command prompt from the start menu and type in set|more it displays the environment variables in command prompt, but it does not allow me to copy and paste the text into the post. My clipboard just pastes the message from above in again

    'C:\Windows\system32\command.bat' is not recognized as an internal or external c
    ommand,
    operable program or batch file.
    Press any key to continue . . .

    I am seeing the line 

    ComSpec=C:\WINDOWS\system32\cmd.exe 

    in the environment variables though. 

    Sorry if this is not as clear as you need it to be. I am just wondering why my command prompt is giving me this message that the batch file is not recognized as an internal or external command, operable program or batch file. I feel that this problem is independent of VS, but is showing up when VS executes code.

    When I run Visual Studios 2008 from the start menu and compile and execute the code it runs my program, but displays the exact same message

    'C:\Windows\system32\command.bat' is not recognized as an internal or external c
    ommand,
    operable program or batch file.

    before the code executes.

    I would love to try and answer any more questions you might have that might help me solve this problem.
    Thanks so much in advance.










    Monday, November 09, 2009 1:17 AM
  • The symptoms you describe indicate that something is not configured
    correctly on your system. It clearly is not unique to or limited to
    VC++ or VS.

    A few observations on the info you have supplied in your last post:

    Quote>When I create a project and try to execute the code the program compiles
    Quote>and tells me there are build errors.
    Quote>If I click to continue it runs the programs

    No, it can't do that. If there are build errors there will be no program
    to run.

    Quote>When I click on "run" from the start menu, it does not allow me to copy
    Quote>and paste the text ...

    I have no idea what you're talking about. When you select "Run" from the
    Start Menu it should open a dialog with an edit box for you to type the
    name of the program you want to run.

    Quote>but it displays the message

    StartQuote>
    Microsoft (R) Windows DOS
    (C)Copyright Microsoft Corp 1990-2001

    C>
    <EndQuote

    This will appear when you start the 16-bit shell, "command.com"

    When you start the 32-bit shell, cmd.exe, you will see a message such as this:

    Microsoft Windows XP [Version 5.1.2600]
    (C) Copyright 1985-2001 Microsoft Corp.

    (Vista should be similar.)

    Quote>when I open command prompt from the start menu
    ...
    Quote>it does not allow me to copy and paste the text into the post.

    How are you trying to copy to the clipboard?

    You should be using the System Menu at the left of the title bar of the
    console window. Click on the System Menu, select Edit, then Mark. Move
    the flashing cursor to the start of the text to be copied, hold the
    shift key down and move to the end of the selection then press Enter.
    Or just choose Select All and press Enter. You should also be able to
    right-click anywhere on the console window to get the Edit menu to pop up.

    Use the Clipboard Viewer to confirm that the copy succeeded.

    Quote>I am just wondering why my command prompt is giving me this message
    Quote>that the batch file is not recognized as an internal or external
    Quote>command, operable program or batch file.

    Because no such file exists.

    Quote>I feel that this problem is independent of VS, but is showing up when
    Quote>VS executes code.

    That appears to be correct. It shows up whenever you try to open a console
    window. Something is not configured correctly in your Windows installation.

    Check your search path (and then your entire hard disk) for a file named
    cmd.bat and if found examine its contents. If such a file exists, for example
    in windows\system32, it may get executed whenever you run "cmd" instead of
    or before cmd.exe gets executed.

    To demonstrate, if I create a file in windows\system32 named cmd.bat and
    I put these lines in it:

    @echo off
    call C:\Windows\system32\command.bat
    cmd.exe

    then whenever I run cmd (no extension) I will see this output on the screen:

    C:\>cmd
    'C:\Windows\system32\command.bat' is not recognized as an internal or external
    command,
    operable program or batch file.
    Microsoft Windows XP [Version 5.1.2600]
    (C) Copyright 1985-2001 Microsoft Corp.

    C:\>

    In short, if someone or something has created a batch file named cmd.bat
    which was intended to first call a file named command.bat and then invoke
    the 32-bit shell, cmd.exe, you will get the results you are seeing. (Assuming
    that command.bat does not now exist.)

    - Wayne
    • Edited by WayneAKing Monday, November 09, 2009 4:46 AM added "call" to bat example
    Monday, November 09, 2009 4:39 AM
  • Thanks for your help.

    I am sorry for not clarifying the steps I took to open command prompt. 

    This is the text that appears when I open up command prompt from the list of applications in my start menu and type in path

    Microsoft Windows [Version 6.0.6002]
    Copyright (c) 2006 Microsoft Corporation.  All rights reserved.
    'C:\Windows\system32\command.bat' is not recognized as an internal or external c
    ommand,
    operable program or batch file.

    C:\Users\Levster>path
    PATH=C:\Program Files\Common Files\Microsoft Shared\Windows Live;C:\Windows\syst
    em32;C:\Windows;C:\Windows\System32\Wbem;C:\Program Files\QuickTime\QTSystem\;C:
    \Program Files\Microsoft SQL Server\90\Tools\binn\;C:\Program Files\Common Files
    \Microsoft Shared\Windows Live

    C:\Users\Levster>

    Then, when I open run and type in command.com and type in path, the following text is displayed

    Microsoft(R) Windows DOS
    (C)Copyright Microsoft Corp 1990-2001.

    C:\USERS\LEVSTER>path
    PATH=C:\PROGRA~1\COMMON~1\MICROS~1\WINDOW~1;C:\Windows\system32;C:\Windows;C:\Wi
    ndows\System32\Wbem;C:\PROGRA~1\QUICKT~1\QTSyste

    C:\USERS\LEVSTER>

    I ran a search to locate a file cmd.bat or command.bat, but there was no file called that on my hard drive. I am not sure how to search the path.

    If a file command.bat does not exist, is there a way I can reconfigure the way command prompt starts in Windows or do I need to reinstall Windows to make command prompt work without the command.bat file? Or is there something else I need to do?
    Tuesday, November 10, 2009 2:32 AM
  • Two things of note in your last post (if accurate) which were not
    obvious from your prior posts:

    (1) The message does not appear when you open the 16-bit shell (command.com)

    (2) When you open the 32-bit shell (cmd.exe) the message appears *after*
    the shell opens, not before.

    Quote>If a file command.bat does not exist, is there a way I can reconfigure
    Quote>the way command prompt starts in Windows or do I need to reinstall
    Quote>Windows to make command prompt work without the command.bat file?

    As I don't have Vista installed, I'm averse to making suggestions re
    configuring that OS version.

    I don't know why you're obsessing about this. It's an informational message
    only. The command prompts are working. If you want to go to all the trouble
    of reinstalling Windows and all of your software, just to eliminate an
    innocuous message, it's your dime/time. If it were happening on my PC and
    I couldn't track down the source, I would give it what it wants. Create a
    simple command.bat file in C:\windows\system32 such as:

    @echo off
    rem Dummy file to appease Windows and let me sleep at night


    The message should go away when you open a command prompt.

    As previously noted by Sheng Jiang, this has nothing to do with Visual C++
    and therefore is off-topic in this forum. If you need to pursue it further,
    I suggest you find a Vista support forum or newsgroup.

    - Wayne
    • Marked as answer by tobymacfan Tuesday, November 10, 2009 7:17 AM
    Tuesday, November 10, 2009 3:10 AM
  • Thanks for your help. This solved the problem I was having with command prompt.
    Tuesday, November 10, 2009 7:17 AM