Calling another program
-
Hi, I am trying to call an external program which operates in a Dos Shell from my Property-Page based MFC project. It takes an input data file and outputs another data file. Any suggestions? kash
I think you may call _spawnl with arguments..or May goto for ShellExecute..what else you want ?
-
I think you may call _spawnl with arguments..or May goto for ShellExecute..what else you want ?
Just tried ShellExecute, which consequently is a pretty cool function. I'm trying to run a program in a different directory to the one my MFC project is kept in. I tried this: ShellExecute(NULL,"open","d:\My Documents\Folder\ProgramA.exe",NULL,NULL,SW_SHOWNORMAL); but it doesn't like the different folder. kash
-
Just tried ShellExecute, which consequently is a pretty cool function. I'm trying to run a program in a different directory to the one my MFC project is kept in. I tried this: ShellExecute(NULL,"open","d:\My Documents\Folder\ProgramA.exe",NULL,NULL,SW_SHOWNORMAL); but it doesn't like the different folder. kash
You maybe need to escape the backslashes in your string:
ShellExecute(NULL,"open","d:\\MyDocuments\\Folder\\ProgramA.exe",NULL,NULL,SW_SHOWNORMAL);
My opinions may have changed, but not the fact that I am right.
-
You maybe need to escape the backslashes in your string:
ShellExecute(NULL,"open","d:\\MyDocuments\\Folder\\ProgramA.exe",NULL,NULL,SW_SHOWNORMAL);
My opinions may have changed, but not the fact that I am right.
-
yep that works but now the dos console opens up but doesn't initialise my ProgramA.exe. It just displays an empty dos window and hangs up.
Kash wrote: It just displays an empty dos window and hangs up. I just tested with
ipconfig.exe
. It opens for a fraction of a second and closes. Maybe it is in your ProgramA.exe?
My opinions may have changed, but not the fact that I am right.
-
Kash wrote: It just displays an empty dos window and hangs up. I just tested with
ipconfig.exe
. It opens for a fraction of a second and closes. Maybe it is in your ProgramA.exe?
My opinions may have changed, but not the fact that I am right.
ProgramA.exe is fine when it's run outside my MFC project. The dos prompt works as it should when i call it explicitly but am getting problems when i call a program. Also all windows programs are executing correctly. I need ProgramA to work and hold until I have operated on it then i want to exit ProgramA and return to the MFC project. Kash
-
ProgramA.exe is fine when it's run outside my MFC project. The dos prompt works as it should when i call it explicitly but am getting problems when i call a program. Also all windows programs are executing correctly. I need ProgramA to work and hold until I have operated on it then i want to exit ProgramA and return to the MFC project. Kash
Kash wrote: I need ProgramA to work and hold until I have operated on it then i want to exit ProgramA and return to the MFC project. I do not understand this sentence. Do you want programA to start in a DosBox, perform its function and close the dosbox? This works on my computer. Or do you need the dos box to stay open, to show the output of ProgramA?
My opinions may have changed, but not the fact that I am right.
-
Kash wrote: I need ProgramA to work and hold until I have operated on it then i want to exit ProgramA and return to the MFC project. I do not understand this sentence. Do you want programA to start in a DosBox, perform its function and close the dosbox? This works on my computer. Or do you need the dos box to stay open, to show the output of ProgramA?
My opinions may have changed, but not the fact that I am right.
-
the latter, as ProgramA requires user inputs and once these have been obtained, it can then perform it's function and be exited by the user.
Kash wrote: ProgramA requires user inputs Oh. I see. From you first post ("It takes an input data file and outputs another data file.") on, I always thought of command line params. For a test, I tried "more.com", (which also wants input) with ShellExecuteEx():
CString s ("C:\\WINNT\\system32\\more.com");
SHELLEXECUTEINFO SEI = {0};
SEI.cbSize = sizeof(SEI);
SEI.lpVerb = "open";
SEI.lpFile = s;
SEI.nShow = SW_SHOWDEFAULT;BOOL err = ::ShellExecuteEx( &SEI );
if (err!=TRUE)
{
}and it seems to work. If this does not help, maybe calling a Batch-file that in turn calls your program may help?
My opinions may have changed, but not the fact that I am right.
-
Kash wrote: ProgramA requires user inputs Oh. I see. From you first post ("It takes an input data file and outputs another data file.") on, I always thought of command line params. For a test, I tried "more.com", (which also wants input) with ShellExecuteEx():
CString s ("C:\\WINNT\\system32\\more.com");
SHELLEXECUTEINFO SEI = {0};
SEI.cbSize = sizeof(SEI);
SEI.lpVerb = "open";
SEI.lpFile = s;
SEI.nShow = SW_SHOWDEFAULT;BOOL err = ::ShellExecuteEx( &SEI );
if (err!=TRUE)
{
}and it seems to work. If this does not help, maybe calling a Batch-file that in turn calls your program may help?
My opinions may have changed, but not the fact that I am right.