Results 1 to 8 of 8

Thread: QString problem?

  1. #1
    Join Date
    Jan 2006
    Posts
    273
    Thanks
    42
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Red face QString problem?

    Hi,

    This comand is working under dos:
    Qt Code:
    1. psexec \\stchps426 -u administrator -p password -c -e -f -n 6 "i:\Adobe Reader7.0.exe" >log.txt 2>&1
    To copy to clipboard, switch view to plain text mode 

    This is running but the parameter >log.txt 2>&1 not:
    Qt Code:
    1. QString zeichen = "\"";
    2. QString zeichen2 = " >log.txt 2>&1";
    3. QString exePath = "psexec.exe";
    4. QString arguments = "\\\\" + hostname + " -u " + username + " -p " + password + " -c -e -f -n 6 " + zeichen + path + "\\" + software + zeichen + zeichen2;
    5. #ifdef Q_OS_WIN32
    6. ShellExecute(NULL, NULL, (LPCWSTR)exePath.toStdWString().data(), (LPCWSTR)arguments.toStdWString().data(), NULL, SW_HIDE);
    7. #endif
    To copy to clipboard, switch view to plain text mode 

    Can somebody see why?
    Think DigitalGasoline

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QString problem?

    Are you sure that ShellExecute knows what to do with ">" and "2>&"? Those characters are interpreted by cmd.exe, so you have to run psexec through cmd.exe.

  3. #3
    Join Date
    Jan 2006
    Posts
    273
    Thanks
    42
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: QString problem?

    Hi,

    no i don't know what ShellExecute do with this special signs

    What u mean with "run psexec through cmd.exe"??
    Think DigitalGasoline

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QString problem?

    Quote Originally Posted by raphaelf View Post
    no i don't know what ShellExecute do with this special signs
    IMO it just passes them to the application which doesn't know what to do with them either.

    Quote Originally Posted by raphaelf View Post
    What u mean with "run psexec through cmd.exe"??
    Run: cmd.exe /c "psexec ... >log.txt 2>&1"

  5. #5
    Join Date
    Jan 2006
    Posts
    273
    Thanks
    42
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: QString problem?

    Hi,

    it works but not in hide modus
    the dos window apears for a moment..

    What is wrong?

    Qt Code:
    1. QProcess *process = new QProcess(this);
    2. process->startDetached("cmd.exe /c psexec.exe \\\\stchps426 -c -e -f -n 6 i:\\WinZip8.1.exe >log.txt 2>&1");
    To copy to clipboard, switch view to plain text mode 
    Think DigitalGasoline

  6. #6
    Join Date
    Jan 2006
    Location
    Bremen, Germany
    Posts
    554
    Thanked 86 Times in 81 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QString problem?

    Use QProcess without cmd.exe and read out stdout and stderr with the appropriate QProcess functions.

  7. #7
    Join Date
    Jan 2006
    Posts
    273
    Thanks
    42
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: QString problem?

    I dont know how to do this..

    could aomebody help me or give me more details?
    Think DigitalGasoline

  8. #8
    Join Date
    Jan 2006
    Posts
    273
    Thanks
    42
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: QString problem?

    I solved like that:
    Qt Code:
    1. QProcess *process = new QProcess(this);
    2. QString zeichen = "\"";
    3. QString program = "psexec.exe \\\\" + hostname + " -u " + username + " -p " + password + " -i -c -e -f -n 6 " + zeichen + path + "\\" + software + zeichen;
    4. process->start(program);
    To copy to clipboard, switch view to plain text mode 
    Think DigitalGasoline

Similar Threads

  1. plugin loading problem
    By naresh in forum Qt Programming
    Replies: 6
    Last Post: 9th June 2007, 19:05
  2. Problem in converting QString to QChar array?
    By KaKa in forum Qt Programming
    Replies: 2
    Last Post: 19th March 2007, 00:38
  3. Convert from iso-8859-1 to... Something else :-)
    By Nyphel in forum Qt Programming
    Replies: 4
    Last Post: 7th March 2007, 17:59
  4. QString problem
    By vermarajeev in forum Qt Programming
    Replies: 9
    Last Post: 26th October 2006, 19:10
  5. Problem with custom widget
    By jnana in forum Qt Programming
    Replies: 3
    Last Post: 15th March 2006, 11:55

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.