Hi,
I'm trying to use the system() command to invoke "eseutil.exe" and store the output in a text file using VC++. The way i used this command is mentioned below.

code snippet:
=========

string command= "\"C:\\Program Files\\Microsoft\\Exchange Server\\Bin\\eseutil.exe\" /mh \"F:\\fsg\\edb\\mailbox database.edb\" | find \"Log Required\" >output.txt";

system(command.c_str());

Compilation is success. But while executing the program i'm getting the following error.

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

Few questions:
===========
1. Is it possible to use system command as above (with full path)?
2. Is it mandatory to specify the path or simply like system("eseutil.exe /mh \"F:\\fsg\\edb\\mailbox database.edb\" | find \"Log Required\" >output.txt"); is enough?
3. If path is not specified to eseutil, will system command automatically detects the path ?

Can anyone explain or give any link that explains the behavior of system() command ?

Thanks
Inmar

1. Have you tried

string command= "C:\\Program Files\\Microsoft\\Exchange Server\\Bin\\eseutil.exe\" /mh \"F:\\fsg\\edb\\mailbox database.edb\" | find \"Log Required\" >output.txt";

Deleting the first "\ before "C:\\ etc..?

2. I don't think it's necessary to specify the full path. If your app.exe is in the same folder as your program, you can simply specify system(app.exe);

3. Links to 2...the path is not 'automatically' detected but again, if the .exe is in the same folder then I believe you do not need to specify the full path.

Hi,
Thanks for the reply.
I have tried by deleting \" before C: But the same error
Am I doing any mistake in the above syntax ? Please suggest me.

Thanks
Inmar

Have you tried invoking the command directly into cmd just to make sure it works?

Yes....I have tried the following

system("eseutil.exe /mh \"F:\\fsg\\edb\\mailbox database.edb\" | find \"Log Required\" >output.txt")

Also manually ran the command from the command prompt

Both works fine.

But I want to achieve the task by specifying the path to eseutil.exe

Help !!!!!

Try popping in a %20 for the space
"C:\\Program%20Files\\Microsoft\\Exchange%20Server\\Bin\\eseutil.exe\"
Having the path in quotation marks should take care of that but it seems like in your other example it's truncating based on the space.

When I use,

C:\program%20files\microsoft\exchange%20server\bin\eseutil.exe /mh "F:\fsg\edb\mailbox database.edb" | find "Log Required" >output.txt

The error is
"The system cannot find the path specified."

system() is prohibited on Windows.
Use SE() or any other api

commented: No, it's not. Windows is not redefining the C++ standard -2

system() is prohibited on Windows.
Use SE() or any other api

Patently false.

I use

command.Format("wget %s -O C:\\Path\\log\\%s.mp3", testAudio, timeStamp);	// format command do download audio (check if present)
system(command);

in some of my code and it works just fine under all versions of Windows on which I've tried it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.