• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 267
  • Last Modified:

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.

0
highmarks
Asked:
highmarks
  • 2
  • 2
  • 2
  • +2
1 Solution
 
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
Simplify Active Directory Administration

Administration of Active Directory does not have to be hard.  Too often what should be a simple task is made more difficult than it needs to be.The solution?  Hyena from SystemTools Software.  With ease-of-use as well as powerful importing and bulk updating capabilities.

 
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
 
kishk91Commented:
you can try WinExec() too.
0

Featured Post

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

  • 2
  • 2
  • 2
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now