Important: Please read the Qt Code of Conduct -

Reload environment on runtime

  • Hi,

    I would like to know if possible to reload the environment on runtime. Imagine the following situation. The application start and this add a path to the system, so How Do I reload the environment again that my application can see the new path?

    Thanks for your help

  • @PabloArg

    Apparently, yes with systemEnvironment
    You might want to chekc this out.

  • I saw that option but looks only apply if you are running some Qprocess later. But in my case I am running an external app using ShellExecuteEx of windows. I don't know if I can use it, I tried before without success.

    QProcess process;
    QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
    env.insert("TMPDIR", "C:\MyApp\temp"); // Add an environment variable
    env.insert("PATH", env.value("Path") + ";C:\Bin");

  • I have a button that contain the following code:
    QStringList env(QProcess::systemEnvironment());
    qDebug() << env ;

    With my app still running I added a new path from System Property ->environment variable.

    So I click in the button but my new path doesn't show up, any ideas?

  • @PabloArg

    Nope. Unfortunately the only possibility I saw.

Log in to reply