Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9222257
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T03:47:42+00:00 2026-06-18T03:47:42+00:00

I am writing a windows QT app that needs to launch other apps. If

  • 0

I am writing a windows QT app that needs to launch other apps. If I use the following windows calls everything works fine:

QString qsExePath = "C:\\Program Files (x86)\\Some Company\\SomeApp.exe";
QString qsCommandLine = "";


DWORD dwLastError = 0;
STARTUPINFO startupInfo;
ZeroMemory(&startupInfo, sizeof(startupInfo));
startupInfo.cb = sizeof(startupInfo);
startupInfo.dwFlags = STARTF_USESHOWWINDOW;
startupInfo.wShowWindow = (WORD)1;

PROCESS_INFORMATION processInfo;
ZeroMemory(&processInfo, sizeof(processInfo));

if (CreateProcess((TCHAR*)(qsExePath.utf16()), (TCHAR*)(qsCommandLine.utf16()), 
    NULL, NULL, FALSE, 0, NULL, NULL, 
    &startupInfo, &processInfo))
{
    CloseHandle(processInfo.hProcess);
    CloseHandle(processInfo.hThread);
}
else
{
    dwLastError = GetLastError();
}

However, if I use the following QT calls it does not work and fails with QProcess::Unknown Error.

QProcess process;
bool bStarted = process.startDetached(qsExePath);
qDebug()  << process.error();   

I can get QProcess to work if copy SomeApp.exe to my %TMP% directory and change the qsExePath accordingly, so it is obviously some kind of permissions error. I don’t understand why though… if it were really permissions, shouldn’t my CreateProcess windows call fail?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T03:47:43+00:00Added an answer on June 18, 2026 at 3:47 am

    Your path has spaces in it. You are calling the overloaded version of QProcess.startDetached() that takes a single parameter, so it interprets that as the complete command line to execute. As such, try wrapping the path in quotes, otherwise it will think that “C:\Program” is the program to execute and everything else are arguments, which would be wrong:

    QString qsExePath = "\"C:\\Program Files (x86)\\Some Company\\SomeApp.exe\"";
    bool bStarted = process.startDetached(qsExePath);
    

    Alternatively, call one of the other overloaded versions of startDetached() and let it work out the necessary quoting internally for you:

    QString qsExePath = "C:\\Program Files (x86)\\Some Company\\SomeApp.exe";
    bool bStarted = process.startDetached(qsExePath, QStringList());
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing a Windows Phone 7 app that needs to be location aware. Specifically
I'm writing a Windows .NET app that needs a WYSIWYG text editor control that
So I am writing a little app that needs to have one JPanel be
I am writing an application that needs to bring window of an external app
I'm writing a wxPython app that needs to match the appearance of an existing
I am writing a Windows 8 App that will primarily run in the background.
I'm writing a desktop app that must work on both Linux and Windows because
I'm writing an app that needs to get the longitude and latitude from the
I need to write a web app (that also works offline) for windows and
I'm writing a small app that needs to list files from multiple paths. Iv

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.