Solved

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

Posted on 2006-07-03
8
260 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
Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

 
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

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

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

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.  …
With most software applications trying to cater to multiple user needs nowadays, the focus is to make them as configurable as possible. For e.g., when creating Silverlight applications which will connect to WCF services, the service end point usuall…
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…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

803 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