Reputation: 247
i would like to execute a batch file from a program (exe file). i usually create the batch file while program (exe file) execution. and will the execl("START","",NULL);
the function is calling the batch file, but unfortunately new command window is showing up as the execl function is process START and parses as “cmd.exe /k " .
can you please share the easiest way to call the function which executes the batch file in background, if possible please share the code snippet.
Upvotes: 2
Views: 4435
Reputation: 354516
Don't use start
but cmd /c
.
ETA: As Chris Jester-Young notes in a comment, this will then look like
execlp("cmd", "/c", batchfile, static_cast<char*>(0))
in your code.
ETA 2: It appears that you don't even need cmd
there. Just the batch file as command should suffice. Since start
worked and start
is a built-in command of cmd.exe
there has to be an instance of cmd
running for your original invocation to work. So just execute the batch file as if it were the program, this should suffice.
Upvotes: 1