Solved

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

Posted on 2006-07-03
8
257 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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
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 Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

This tutorial is about how to put some of your C++ program's functionality into a standard DLL, and how to make working with the EXE and the DLL simple and seamless.   We'll be using Microsoft Visual Studio 2008 and we will cut out the noise; that i…
This article shows a few slightly more advanced techniques for Windows 7 gadget programming, including how to save and restore user settings for your gadget and how to populate the "details" panel that is displayed in the Windows 7 gadget gallery.  …
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…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

708 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

18 Experts available now in Live!

Get 1:1 Help Now