Search code examples
windowsqtwindows-explorerqprocess

Restart Windows' explorer.exe via QProcess


At first, the Windows explorer.exe was closed and the desktop screen went black. My program needs to start explorer.exe. This is I tried:

QProcess process;
process.execute("explorer.exe");

The problem is this only pops up a new explorer window instead of reactivating the desktop explorer (turn the black screen back to desktop). It should behave just like when you run explorer.exe after you kill it in cmd or powershell.


Solution

  • Solution found:

    QProcess::startDetached("explorer.exe"); //Wrong
    QProcess::execute("C:\\Windows\\explorer.exe"); //Wrong
    QProcess::startDetached("C:\\Windows\\explorer.exe"); //Right
    

    If anyone knows why explorer.exe behaviour like this, please share it.