How would i get my prog to run a file in the same dir like a *.bat file and if poss not make it open in a window
How would i get my prog to run a file in the same dir like a *.bat file and if poss not make it open in a window
Since you said .bat file I assume you are using windows. Look up the documentation on CreateProcess(). There is a flag you send so it will inherit the current console.
why do you assume he's using windows for .bat files? Batch files are for DOS, not windows, even though you can use them to run windows programs.
here you go
system() is what you would useCode:#include <iostream.h> #include <stdlib.h> int main() { cout<<"Running sekti.bat"<<endl; system("sekti.bat"); cout<<"Boom"<<endl; return 0; }
+++
++
+ Sekti
++
+++
i am using wind0ze btw but not all bat commands work?
summit to do with sharing violation
i thinks its cus the file has been opened in my prog but do i have to close it then?
You are using windows, so use create process. Here is an example:
STARTUPINFO s; /* INPUT PARAMETER */
PROCESS_INFORMATION p; /* OUTPUT PARAMETER */
char* filename = "c:\autoexec.bat"; /* FILE TO EXECUTE */
/* SEARCH DOCS FOR ALL THE THINGS YOU CAN DO WITH A
STARTUPINFO STRUCTURE */
s.cb = sizeof(STARTUPINFO);
s.lpReserved = NULL;
s.lpDesktop = NULL;
s.lpTitle = NULL;
s.cbReserved2 = 0;
s.lpReserved2 = NULL;
s.dwFlags = STARTF_USESTDHANDLES;
s.hStdInput = GetStdHandle (STD_INPUT_HANDLE);
s.hStdOutput = GetStdHandle (STD_OUTPUT_HANDLE);
s.hStdError = GetStdHandle (STD_OUTPUT_HANDLE);
// SEARCH DOCS FOR INFO ON ARG OPTIONS TO
// CREATEPROCESS
if (!CreateProcess(
NULL,
filename,
NULL,
NULL,
FALSE,
0,
NULL,
NULL,
&s,
&p ) )
printf("Couldnt create process1\n");