Question

Hallo dear stackoverflow users,

I have a problem trying to run a command using QProcess on windows. Everything works fine except the interpretation of one argument.

I am calling the vcbuild.exe to build a visual studio 2008 solution. The call looks like this:

    QString program = "cmd.exe";
    QStringList arguments;
    arguments << getenv(VS90COMNTOOLS) + "\\vsvars32.bat"
      << "&" << "vcbuild.exe" << pathToSolution << "Debug|Win32";
    QProcess::execute( program, arguments );

The problem is that a name like "Debug|Win32" is a common configuration name for many solutions i want to be built programmatically calling my program which uses QProcess - but the symbol "|" gets treated as a pipe symbol and windows says: "The command Win32 is wrong or could not be found." (orig. "Der Befehl "Win32" ist entweder falsch geschrieben oder konnte nicht gefunden werden. ")

If I try using quotes:

    arguments << [...] << "\"Debug|Win32\""

The error is: "vcbuild.exe: Error VCBLD0006: Invalid configuration name: "Debug|WIN32"." (orig. "vcbuild.exe: Fehler VCBLD0006: Ungültiger Konfigurationsname: "DEBUG|WIN32".") Obviously the quotes are now part of the name such that the pipe symbol is no longer treated as pipe symbol but now the configuration name is wrong. By try and error I found that Qt wraps it by three quotes. It is as if I would write:

    vcbuild.exe [...] """Debug|Win32"""

The workaround would be to put everything into one large string, but that would be my last unwanted choice, because that way I would have to do all the quoting stuff depending on quotes or spaces on my own.

Does someone know an answer how to solve my problem? Thank you in advance!

Was it helpful?

Solution

Try to use ^ as an escape character, i.e. "Debug^|Win32". See cmd Escape Character for details.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top