-1

I have a problem running phantomjs.exe binary in my QProcess class. Consider this code:

QString program = "phantomjs.exe";
QProcess *process = new QProcess(this);
process->start(program, QStringList() << "test.js");

When I start the app main process loads up and nothing happens after that, just hundreds of other phantomjs.exe are created (checking it in TaskManager) as well as conhost.exe processes.

I tried other exe files, like notepad.exe, and it works just fine. Notepad window appears.

Did you encounter this problem?

Maxim Makhun
  • 2,197
  • 1
  • 22
  • 26
  • I have not seen this and I use QProcess for several of my applications on windows. Although I am limited to Qt-4.8.5 because of library dependencies. – drescherjm Dec 21 '13 at 15:18

2 Answers2

2

Do you call phantom.exit() in your test script?

https://github.com/ariya/phantomjs/wiki/Quick-Start

console.log('Hello, world!');
phantom.exit();

Hope that helps.

phyatt
  • 18,472
  • 5
  • 61
  • 80
0

After checking I found that there is a problem with QProcess. I used SHELLEXECUTEINFO instead. This code works for me well. No recursive calls of phantomjs.exe here:

SHELLEXECUTEINFO shExecInfo;
shExecInfo.cbSize = sizeof(SHELLEXECUTEINFO);

shExecInfo.fMask = NULL;
shExecInfo.hwnd = NULL;
shExecInfo.lpVerb = L"runas";
shExecInfo.lpFile = L"phantomjs.exe";
shExecInfo.lpParameters = L"test.js";
shExecInfo.lpDirectory = NULL;
shExecInfo.nShow = SW_NORMAL;
shExecInfo.hInstApp = NULL;

ShellExecuteEx(&shExecInfo);
Maxim Makhun
  • 2,197
  • 1
  • 22
  • 26