Results 1 to 8 of 8

Thread: arg!!!! QProcess on win32

  1. #1
    Join Date
    Apr 2006
    Location
    San Francisco, CA
    Posts
    186
    Thanks
    55
    Thanked 12 Times in 11 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default arg!!!! QProcess on win32

    Very annoying... I'm trying to pass to QProcess::start() this argument:
    INSTALLDIR="C:\Program Files\Folder"
    However, there's a function call in qprocess_win.cpp called qt_create_commandline that insists on double quoting my argument as so:
    "INSTALLDIR="C:\Program Files\Folder""
    because it sees the space between "Program" and "Files" and thinks that extra quotes are needed. And this causes the external program that I'm start()'ing to parse the argument incorrectly. Arg!! How can I get around this? How can I pass a raw string to start() without the extra Qt argument massaging?
    Software Engineer



  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: arg!!!! QProcess on win32

    What do you need the quotes for? Is "INSTALLDIR" an environment variable you are trying to set or is it a real argument for the program?

  3. #3
    Join Date
    Apr 2006
    Location
    San Francisco, CA
    Posts
    186
    Thanks
    55
    Thanked 12 Times in 11 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: arg!!!! QProcess on win32

    It's not an environment variable, I'm actually trying to set a Windows Installer property for an installer that I'm calling from my Qt program, and this installer is actually quite sensitive to these extra double quotes.

    It seems that the Qt code should attempt to parse the arguments and ignore spaces that are already escaped and enclosed within double quotes, rather than just indiscriminately check if the arg contains a space anywhere in it. And I'd rather not have to try to modify Qt source and I wish there was a way around it... cursed time deadlines
    Software Engineer



  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: arg!!!! QProcess on win32

    Quote Originally Posted by gfunk View Post
    It's not an environment variable, I'm actually trying to set a Windows Installer property for an installer that I'm calling from my Qt program, and this installer is actually quite sensitive to these extra double quotes.
    But do you need any quotes here? Try removing your quotes, they are probably not needed at all.

    It seems that the Qt code should attempt to parse the arguments and ignore spaces that are already escaped and enclosed within double quotes, rather than just indiscriminately check if the arg contains a space anywhere in it. And I'd rather not have to try to modify Qt source and I wish there was a way around it... cursed time deadlines
    Actually I never heard of Qt adding any quotes to parameters. I don't know how this is on Windows, but on Unix systems they are not needed because the argument is simply pushed into the array of arguments passed to execve() later on. Are you certain those quotes are really there? I would be surprised if this behaviour was platform dependent.

    Can you show us the code you have written to spawn the external process?

  5. #5
    Join Date
    Apr 2006
    Location
    San Francisco, CA
    Posts
    186
    Thanks
    55
    Thanked 12 Times in 11 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: arg!!!! QProcess on win32

    Quote Originally Posted by wysota View Post
    But do you need any quotes here? Try removing your quotes, they are probably not needed at all.
    Yes, it needs the quotes around the path, otherwise it will interpret only only up to the first space in the pathname. And the external program won't interpret my argument at all if it has quotes entirely around it. "INSTALLDIR=C:\Program Files\Folder" doesn't work.

    Quote Originally Posted by wysota View Post
    Actually I never heard of Qt adding any quotes to parameters. I don't know how this is on Windows, but on Unix systems they are not needed because the argument is simply pushed into the array of arguments passed to execve() later on. Are you certain those quotes are really there? I would be surprised if this behaviour was platform dependent.
    well, i guess that's why they had to write a qprocess_win.cpp

    Quote Originally Posted by wysota View Post
    Can you show us the code you have written to spawn the external process?
    For the curious, the program is essentially any Windows Installer installer exe, or if you have an msi file, you can run it through with msiexec.exe passing in the property described above, which should be on any Windows computer.

    Qt Code:
    1. QString arg = QString("INSTALLDIR=%1%2%3").arg(QLatin1Char('"'))
    2. .arg(mSetDest.installFolder())
    3. .arg(QLatin1Char('"'));
    4. args << arg;
    5. mpInstallProcess->start(cmd, args);
    To copy to clipboard, switch view to plain text mode 
    Software Engineer



  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: arg!!!! QProcess on win32

    Quote Originally Posted by gfunk View Post
    Yes, it needs the quotes around the path, otherwise it will interpret only only up to the first space in the pathname.
    "It" being the installer? Because your application will treat it as a single argument, I'm sure of that. That's what those additional quotes are for.

    And the external program won't interpret my argument at all if it has quotes entirely around it. "INSTALLDIR=C:\Program Files\Folder" doesn't work.
    Try:
    Qt Code:
    1. QString a = QString("INSTALLDIR=\\\"%1\\\").arg(path);
    To copy to clipboard, switch view to plain text mode 


    For the curious, the program is essentially any Windows Installer installer exe, or if you have an msi file, you can run it through with msiexec.exe passing in the property described above, which should be on any Windows computer.
    Provided one is running Windows... And if the installer can't handle those quotes, it's simply dumb and should be replaced by some more intelligent application.

  7. #7
    Join Date
    Jan 2006
    Location
    Norway
    Posts
    124
    Thanked 38 Times in 30 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: arg!!!! QProcess on win32

    Bitto / Andreas Aardal Hanssen - andreas dot aardal dot hanssen at nokia
    Nokia Software Manager, Qt Development

  8. #8
    Join Date
    Jan 2008
    Posts
    31
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: arg!!!! QProcess on win32

    Have you tried:

    INSTALLDIR=C:\Progra~1\Folder

    Windows provides some backward compatibility to older systems where filenames were restricted to 8 characters.

Similar Threads

  1. QProcess and Pipes
    By KaptainKarl in forum Qt Programming
    Replies: 1
    Last Post: 9th April 2007, 23:11
  2. QProcess extremely slow on Windows?
    By Pepe in forum Qt Programming
    Replies: 2
    Last Post: 26th March 2007, 00:25
  3. Replies: 1
    Last Post: 6th March 2007, 15:27
  4. problem with qprocess
    By deekayt in forum Qt Programming
    Replies: 2
    Last Post: 13th June 2006, 13:30
  5. QProcess in a QThread
    By chombium in forum Qt Programming
    Replies: 2
    Last Post: 11th January 2006, 15:52

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.