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?
 
amer_fConnect With a Mentor Commented:
here is the answer

#include<process.h>

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

 
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
 
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
All Courses

From novice to tech pro — start learning today.