• C

how to execute an .exe file(created in VC++) from C program

Hi!
I have created an .exe file using VC++6.0 with MFC Appwizard (size 560Kb)
Now I have tried executing taht exe from my c program using
execv("c:\test.exe",NULL) and also fork it gives me this error.
Debug Assertion failed expression argvector!=NULL

Can someone suggest me how to execute this.
Thanks.

LVL 2
highmarksAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

imladrisCommented:
The documentation I have for execv says that at least one argument must be supplied for execv. This one (or first) argument will be supplied to the program as argv[0] and usually contains a copy of the cmdname argument.
0
highmarksAuthor Commented:
I have also tried that now it give sme an error of
c:\......??contains an invalid path
0
imladrisCommented:
Please post the code you used to pass the arguments....
0
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

akalmaniCommented:
Hi highmarks !!!
    Hope this helps give the command line arguments

void main( VOID ){    
   STARTUPINFO si;
    PROCESS_INFORMATION pi;
    ZeroMemory( &si, sizeof(si) );
    si.cb = sizeof(si);
    // Start the child process.
    if( !CreateProcess( NULL, // No module name (use command line).
        "MyChildProcess", // Command line.
        NULL,             // Process handle not inheritable.
        NULL,             // Thread handle not inheritable.
        FALSE,            // Set handle inheritance to FALSE.
        0,                // No creation flags.
        NULL,             // Use parent's environment block.
        NULL,             // Use parent's starting directory.
        &si,              // Pointer to STARTUPINFO structure.
        &pi )             // Pointer to PROCESS_INFORMATION structure.    )
        {  
               ErrorExit( "CreateProcess failed." );
         }
     // Wait until child process exits.
     WaitForSingleObject( pi.hProcess, INFINITE );
     // Close process and thread handles.
     CloseHandle( pi.hProcess );
     CloseHandle( pi.hThread );
}
0
highmarksAuthor Commented:
Hi!
The above code does not work the exe should execute when I double click on systray icon.
Send me some executable code
0
roaknogCommented:
0
kishk91Commented:
What about the system command???

like system("c:\\dir\\file.exe");

????
kishk91
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
kishk91Commented:
you can try WinExec() too.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C

From novice to tech pro — start learning today.