Executing a .bat file with a parameter and reading the console output in C++ <p>I have a batch file I need to execute, it has one parameter, If I were to run this script myself I would open up cmd and write</p> <pre><code>lexparser.bat texfile.txt </code></pre> <p>and the output would then be printed to the console. I have shopped around and I have found some code which seems to be executing the file but I can't seem to extract the data being output, but I am unsure if this is correct.</p> <pre><code>QString pathDocument = qApp-&gt;applicationDirPath()+ "/stanford/lexparser.bat"; long result = (long)ShellExecute(0, 0, reinterpret_cast&lt;const WCHAR*&gt;(pathDocument.utf16()), 0, 0, SW_NORMAL); </code></pre> <p>I am using C++ as my language and I am also using the Qt Library to help me. I have limited programming ability so any help would be greatly appreciated</p>