-
October 21st, 2004, 06:18 AM
#1
A Question for all
Hi!
I want to make a program in C or C++ which can run a .bat file from the folder in which the program is stored.
How can i make that file execute from the c program.
The problem is that how can i get to know from the program itself that where the user has stored the file without requesting the user to store it in a particular folder.
-
October 22nd, 2004, 03:42 PM
#2
#include <stdio.h>
int main() {
system("Phile"); //where Phile is the .bat file
return 0;
}
You mean, searching for a file? You could write a function for that, or use some already available library...
The above sentences are produced by the propaganda and indoctrination of people manipulating my mind since 1987, hence, I cannot be held responsible for this post\'s content - me
www.elhalf.com
-
October 23rd, 2004, 08:15 AM
#3
Hi!
I exactly want to know that after the execution of the .bat file will control return to the next line in c program or to the dos prompt.
If to the c program then can another file be executed likewise.
How can the file be searched in folders and subfolders??????????
Please reply soon
-
October 23rd, 2004, 01:19 PM
#4
It returns control to the C program, in the previous example the only thing left to do was exit so...
Code:
#include <stdio.h>
int main() {
system("Phile");
printf("First batch file executed");
system("OtherPhile");
printf("Another file executed");
getch(); //leet pause
return 0;
}
I don't know a good way to search for a file in all directories.
Maybe you could execute a system("dir /AD > dir.txt");
And then read all directories from the dir.txt file into an array or something and use that...
Maybe it is possible in C to read system() output, in Java at least this is possible, my knowledge in C is very limited though in such things.
From a design point of view it would be better of course not to use the method I just mentioned, it should possible to implement this in C relatively uncomplicated.
The above sentences are produced by the propaganda and indoctrination of people manipulating my mind since 1987, hence, I cannot be held responsible for this post\'s content - me
www.elhalf.com
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|