Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

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

Posted on 2006-07-03
8
261 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
8 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
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

zlib is a free compression library (a DLL) on which the popular gzip utility is built.  In this article, we'll see how to use the zlib functions to compress and decompress data in memory; that is, without needing to use a temporary file.  We'll be c…
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
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…

856 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