473,396 Members | 1,879 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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
Apr 4 '07 #1
8 9810
sicarie
4,677 Expert Mod 4TB
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\\
Apr 4 '07 #2
yeah ..
i tried it but its still giving the error ..i.e. output -1

my exe file was developed through turbo c++ itself
Apr 4 '07 #3
sicarie
4,677 Expert Mod 4TB
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?
Apr 4 '07 #4
my program was


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

cout<< i;
}
Apr 4 '07 #5
how about using spawnl()???

but i donno its format..
help me out guys
Apr 4 '07 #6
sicarie
4,677 Expert Mod 4TB
how about using spawnl()???

but i donno its format..
help me out guys
Yeah, I don't know - that code works on my compiler...
Apr 4 '07 #7
oscse
1
U can use any of the following two method:

Expand|Select|Wrap|Line Numbers
  1. #include<stdio.h>
  2. #include<process.h>
  3.  
  4. int main()
  5. {
  6.     int c = execl("C:\\TC\\BIN\\SU.EXE", NULL);
  7.  
  8.     printf("%d",c);
  9.     return 0;
  10. }
  11.  
Expand|Select|Wrap|Line Numbers
  1. #include<stdio.h>
  2. #include<process.h>
  3.  
  4. int main()
  5. {
  6.     int c = spawnl(P_OVERLAY, "C:\\TC\\BIN\\MM.EXE", NULL);
  7.  
  8.     printf("%d",c);
  9.  
  10.     return 0;
  11. }
  12.  
Jul 13 '09 #8
JosAH
11,448 Expert 8TB
@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)
Jul 13 '09 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Travis Stewart | last post by:
Hi, I've been working on some software to control an older GPIB card for the past couple of weeks. I have function prototypes in a header file pc-mate2.h and the functions are defined in...
28
by: Madhur | last post by:
Hello what about this nice way to open a file in single line rather than using if and else. #include<stdio.h> void main() { FILE *nd; clrscr();...
9
by: Casanova | last post by:
Hello! How can I execute other exe files from within a executable file in GCC. In TurboC 3, the spawn command executes a file and returns command to the calling file. whereas in GCC, the exec...
7
by: SunRise | last post by:
Hi I am creating a C Program , to extract only-Printable-characters from a file ( any type of file) and display them. OS: Windows-XP Ple help me to fix the Errors & Warnings and explain...
4
by: BHARAT | last post by:
Hi I am a little bit new to C's advanced topics: I need help in file handling. I have Turbo C and I wrote a simple program to write data to file: #include<stdio.h> #include<dir.h>...
0
by: cudayab | last post by:
ow can i compile and execute an oci program in turbo c. i tried to compile a program with ociw32 library but i got a message like bad object in oci32.lib at some location. pls try to help me...
25
by: rajus | last post by:
I have made a simple program to read the contents of a file.The FILE pointer returns NULL at the very beginning eventhough the file is present.Now if I modify my program and use command line...
28
by: broli | last post by:
I cannot understand why the program goes into infinite loop after the file is printed on the screen. #include<stdio.h> int main(void) { FILE *fp; char c;
6
Parul Bagadia
by: Parul Bagadia | last post by:
This is my first program of file handling... Here we are supposed to simulate sql language...... This is ofcourse not the complete program; m done only with insertion and select* thing; insert...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.