execute a .exe file using turbo c++ program

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • abhisheknaina
    New Member
    • Apr 2007
    • 4

    execute a .exe file using turbo c++ program

    how can an already existing exe file say <filename.exe > be executed using a turbo c++ program....
    i have tried

    system(" path of file");

    but it always returning an error i.e. the integer value it returns is -1.

    help me .... its urgent
  • sicarie
    Recognized Expert Specialist
    • Nov 2006
    • 4677

    #2
    Originally posted by abhisheknaina
    how can an already existing exe file say <filename.exe > be executed using a turbo c++ program....
    i have tried

    system(" path of file");

    but it always returning an error i.e. the integer value it returns is -1.

    help me .... its urgent
    Did you try backwhacking the path to the file? ie - using double backslashes instead of single?

    C:\Windows\ -> C:\\Windows\\

    Comment

    • abhisheknaina
      New Member
      • Apr 2007
      • 4

      #3
      yeah ..
      i tried it but its still giving the error ..i.e. output -1

      my exe file was developed through turbo c++ itself

      Comment

      • sicarie
        Recognized Expert Specialist
        • Nov 2006
        • 4677

        #4
        Originally posted by abhisheknaina
        yeah ..
        i tried it but its still giving the error ..i.e. output -1

        my exe file was developed through turbo c++ itself
        Can I see the system() call you're using?

        Comment

        • abhisheknaina
          New Member
          • Apr 2007
          • 4

          #5
          my program was


          main() {
          int i;
          i = system("c:\\tur boc3\\sim.exe") ;

          cout<< i;
          }

          Comment

          • abhisheknaina
            New Member
            • Apr 2007
            • 4

            #6
            how about using spawnl()???

            but i donno its format..
            help me out guys

            Comment

            • sicarie
              Recognized Expert Specialist
              • Nov 2006
              • 4677

              #7
              Originally posted by abhisheknaina
              how about using spawnl()???

              but i donno its format..
              help me out guys
              Yeah, I don't know - that code works on my compiler...

              Comment

              • oscse
                New Member
                • Jul 2009
                • 1

                #8
                U can use any of the following two method:

                Code:
                #include<stdio.h>
                #include<process.h>
                
                int main()
                {
                	int c = execl("C:\\TC\\BIN\\SU.EXE", NULL);
                
                	printf("%d",c);
                	return 0;
                }
                Code:
                #include<stdio.h>
                #include<process.h>
                
                int main()
                {
                	int c = spawnl(P_OVERLAY, "C:\\TC\\BIN\\MM.EXE", NULL);
                
                	printf("%d",c);
                
                	return 0;
                }

                Comment

                • JosAH
                  Recognized Expert MVP
                  • Mar 2007
                  • 11453

                  #9
                  @oscse: please don't wake up threads that are long dead (see the posting dates). btw, I removed the bold tags and added code tags for readability.

                  kind regards,

                  Jos (moderator)

                  Comment

                  Working...