I think this entire function can be replaced by QProcess::exec