PDA

View Full Version : QString problem?



raphaelf
20th June 2008, 11:36
Hi,

This comand is working under dos:


psexec \\stchps426 -u administrator -p password -c -e -f -n 6 "i:\Adobe Reader7.0.exe" >log.txt 2>&1


This is running but the parameter >log.txt 2>&1 not:


QString zeichen = "\"";
QString zeichen2 = " >log.txt 2>&1";
QString exePath = "psexec.exe";
QString arguments = "\\\\" + hostname + " -u " + username + " -p " + password + " -c -e -f -n 6 " + zeichen + path + "\\" + software + zeichen + zeichen2;
#ifdef Q_OS_WIN32
ShellExecute(NULL, NULL, (LPCWSTR)exePath.toStdWString().data(), (LPCWSTR)arguments.toStdWString().data(), NULL, SW_HIDE);
#endif


Can somebody see why? :crying:

jacek
20th June 2008, 14:16
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.

raphaelf
20th June 2008, 14:26
Hi,

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

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

jacek
20th June 2008, 14:41
no i don't know what ShellExecute do with this special signs :o
IMO it just passes them to the application which doesn't know what to do with them either.


What u mean with "run psexec through cmd.exe"??
Run: cmd.exe /c "psexec ... >log.txt 2>&1"

raphaelf
20th June 2008, 14:59
Hi,

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

What is wrong?



QProcess *process = new QProcess(this);
process->startDetached("cmd.exe /c psexec.exe \\\\stchps426 -c -e -f -n 6 i:\\WinZip8.1.exe >log.txt 2>&1");

ChristianEhrlicher
23rd June 2008, 07:30
Use QProcess without cmd.exe and read out stdout and stderr with the appropriate QProcess functions.

raphaelf
23rd June 2008, 09:08
I dont know how to do this..

could aomebody help me or give me more details? :o

raphaelf
24th June 2008, 10:12
I solved like that:


QProcess *process = new QProcess(this);
QString zeichen = "\"";
QString program = "psexec.exe \\\\" + hostname + " -u " + username + " -p " + password + " -i -c -e -f -n 6 " + zeichen + path + "\\" + software + zeichen;
process->start(program);

:rolleyes: