c++ - Retrieve environment variables of a QProcess -


i want run environment script within qprocess , read environment (as qstringlist) start other scripts environment.

if start env script , read environment, empty qstringlist. there way read out environment of qprocess?

i tried first start environment script , start actual script on same qprocess object did not either.

if able rewrite script sets environment in c++ can create environment , set using
void qprocess::setprocessenvironment ( const qprocessenvironment & environment ) method in example given in method's documenation:

 qprocess process;  qprocessenvironment env = qprocessenvironment::systemenvironment();  env.insert("tmpdir", "c:\\myapp\\temp"); // add environment variable  env.insert("path", env.value("path") + ";c:\\bin");  process.setprocessenvironment(env);  process.start("myapp"); 

update

if can't use above method try using cmd.exe this;

#include <qtcore/qcoreapplication> #include <qtcore/qprocess>  int main(int argc, char *argv[]) {     qcoreapplication app(argc, argv);      qprocess* proc = new qprocess();     proc->start("cmd.exe /c \"call env.bat && script.bat\"");      return app.exec(); } 

having env.bat contents

set abc=test 

and script.bat contents

echo %abc% > a.txt 

running above creates a.txt file contents

test  

Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -