• 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.

laeuchliCommented:
well, change execv("c:\test.exe",NULL)
to execv("c:\\test.exe",NULL) you need to '\' to make it work. If this doesn't help you will have to post more of your code.
0
highmarksAuthor Commented:
HI!
I have tried that too but does not work.
Actually I have written a code for systray icon when I double click that icon exe should run.
Now it's giving me error of c:\sample....invalid path??????
0
roaknogCommented:
// You need more than one argument in last variable of execv,
// but last arguement needs to be null.

#include <stdio.h>
#include <process.h>


void main(){
      char *args[3],pn[50];
      args[0] = "whatever";
      args[1] = "blah blah";
      args[2] = NULL;
      printf("     Enter executable's path: ");
      gets(pn);
      int x = execv(/*"c:\\temp\\name.exe"*/pn,args) ;
      printf("\n     execv output error # %d\n\n     ",x);
      }

// If you want to do this in assembly got to:
// http://www.geocities.com/freehafer/pl2.html#EXEC
0
Get Certified for a Job in Cybersecurity

Want an exciting career in an emerging field? Earn your MS in Cybersecurity and get certified in ethical hacking or computer forensic investigation. WGU’s MSCSIA degree program was designed to meet the most recent U.S. Department of Homeland Security (DHS) and NSA guidelines.  

roaknogCommented:
// IF YOU HAD TO EXECUTE THE FOLLOWING PROGRAM:
#include "stdio.h"//printf
#include "windows.h"//toupper BYTE

void main(int argc, char **argv)
{
      printf("The character entered is: %c!",argv[1][0]);
      printf("\nIts integral representation is: %i!",int((toupper(argv[1][0])-'A') +1));
      printf("\nIts upper case character representation after conversion from byte is: %c!",'A' + BYTE((toupper(argv[1][0])-'A') +1) - 1);
}

// YOU WOULD WRITE:
//  name.exe a
// AT THE COMMAND LINE TO OUTPUT a 1 A
// BUT args[0] DOES NOT NECESSARILY HAVE TO
// BE THE PROGRAM NAME THOUGH IT USUALLY IS,
// YET args[1] HAS TO BE THE LOWER CASE a.
      #include <stdio.h>
                #include <process.h>


                void main(){
                char *args[3];
                args[0] = "junk";//"c:\\temp\\x.exe";
                args[1] = "a:";
                args[2] = NULL;
                printf("     Enter executable's path: ");
                int x = execv("c:\\temp\\x.exe",args) ;
                printf("\n     execv output error # %d\n\n     ",x);
                }
0
highmarksAuthor Commented:
Hi! All
I have got the answer regarding it is
WinExec(.....)
0
roaknogCommented:
Thank you for your thoughtful evaluation of my answer.
0
akalmaniCommented:
Hi highmarks!!!!
 hope u got the answer
Evaluate this answers or delete these questions please
0
amer_fCommented:
here is the answer

#include<process.h>

spawnl(P_WAIT, "c:\\test.exe",NULL);
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
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.