Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How to troubleshooting "Command interpreter cannot be found" error?

Posted on 2006-07-03
8
Medium Priority
?
270 Views
Last Modified: 2013-12-03
I use c function "system" to run some command. However, I got a ENOENT error, which means "Command interpreter cannot be found."

Then I check c:\winnt\system32(it's w2k) folder, CMD.exe is there! and I check the path, no problem. And the command I run do exist, I can open a cmd window then perform it. So, why can't I use "system" function to call it? What am I missed?
0
Comment
Question by:Struggler
  • 4
  • 2
7 Comments
 
LVL 5

Expert Comment

by:bastibartel
ID: 17036704
Hi there,

Can you launch cmd.exe from the Start-Menu ?
Can you use system() with the full path to cmd.exe ?

Cheers,
Sebastian
0
 

Author Comment

by:Struggler
ID: 17037397
Hi bastibartel:

     Thanks for your help.
     I can launch cmd.exe from the start  menu;
     system() need to specify cmd.exe or it's full path. c runtime should automatically found the shell and lanuch it.

     btw, the machine has IIS installed, it's a web server. any security setting could prevent system() succeed?
0
 
LVL 5

Expert Comment

by:bastibartel
ID: 17037557
Hi there,

I was just wondering if it's an issue with the environment variable PATH.
If you try to specify the complete path to cmd.exe, we would know.

OK - after you tried the full path, try any other application, like notepad.exe - again with the full path.
I don't think it's a security issue.

If you cannot use system(), try

#include <process.h>
spanwl(_P_NOWAIT,"C:\\windows\\notepad.exe", "notepad.exe", NULL, NULL);
//** doublecheck the path to notepad - it might differ

or cmd.exe, respectively.
The first argument _P_NOWAIT, determines, whether spawn will return immediately or wait til the spawned program has terminated.
The second argument to spawnl is the full path.
The third arg is the usually the name of the program, but it should not matter really.
The fourth, .. arguments are command line parameters, the last argument MUST be NULL)



Cheers,
Sebastian
0
What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

 
LVL 5

Expert Comment

by:bastibartel
ID: 17047125
Hi Struggler

Have you had any success with my siuggestions ?

Cheers,
Sebastian
0
 

Author Comment

by:Struggler
ID: 17189611
Hi Sebastian:

      Thanks for your suggestion. What I need is not to change my code, but to find why it doesn't work in customer's Env. And eventually I found that, in customer's env, his COMSPEC variables is not correctly configured. c run-time lib needs this variable to know which shell it could used.

       Now the problem have solved completely. Thanks for the help you've given.

To others want to know more about this:
I've states all this in my blog:http://blog.aarony.net, but it's in chinese.
0
 
LVL 5

Expert Comment

by:bastibartel
ID: 17190950
Congratz to you for finding it then ;-)

So the answer would be ( for all those not fluent in Cantonese)

If the function system() cannot find the command interpreter cmd.exe and hence returns ENOENT,
then check your ComSpec environment variable.

Cheers,
Sebastian

0
 

Accepted Solution

by:
CetusMOD earned 0 total points
ID: 17395629
PAQed with points refunded (50)

CetusMOD
Community Support Moderator
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes a technique for converting RTF (Rich Text Format) data to HTML and provides C++ source that does it all in just a few lines of code. Although RTF is coming to be considered a "legacy" format, it is still in common use... po…
This article surveys and compares options for encoding and decoding base64 data.  It includes source code in C++ as well as examples of how to use standard Windows API functions for these tasks. We'll look at the algorithms — how encoding and decodi…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…

877 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