Results 1 to 10 of 10

Thread: how to get error or informations from a exe under dos?

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

    Red face how to get error or informations from a exe under dos?

    Hi Everybody,

    i am using a small dos program to push a software to clients and its working great.

    But i would like to get errors or information from this exe..

    If i run this exe under dos i get for example host not found or copy complete..

    How could i get this messages and put for example in a messagebox?

    With this script i start my program in hide modus:
    Qt Code:
    1. QString zeichen2 = "\"";
    2. QString exePath2 = "psexec.exe";
    3. QString arguments2 = "\\\\" + hostname + " -u " + username + " -p " + password + " -c -d -e -f -i -n 6 " + zeichen2 + path + "\\" + software + zeichen2;
    4. #ifdef Q_OS_WIN32
    5. ShellExecuteW(NULL, NULL, (LPCWSTR)exePath2.toStdWString().data(), (LPCWSTR)arguments2.toStdWString().data(), NULL, SW_HIDE);
    6. #endif
    To copy to clipboard, switch view to plain text mode 
    Please help me
    Think DigitalGasoline

  2. #2
    Join Date
    Jun 2008
    Posts
    12
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: how to get error or informations from a exe under dos?

    To use messageBox you'll have to use QtGui.
    You want DOS, so i suggest yout to use qWarning, qDebug methods...
    However, if you want your executed exe to show more informations, u'll have to modify sources...

    I'm not quite sure that I answered you ^^

  3. #3
    Join Date
    Jan 2006
    Posts
    122
    Thanks
    16
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: how to get error or informations from a exe under dos?

    Use QProcess, and connect a slot to readyReadStandardOutput().
    You can then parse the output and whatever you need.

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

    Default Re: how to get error or informations from a exe under dos?

    Hi, but if i use QProcess, im not able to run my exe in hide modus..

    Its not possible to use my script, but to get messages from this exe?
    Think DigitalGasoline

  5. #5
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: how to get error or informations from a exe under dos?

    Did you read what MSDN has to say about ShellExecute(), ShellExecuteEx() and co?
    J-P Nurmi

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

    Default Re: how to get error or informations from a exe under dos?

    if i have understand with the function ShellExecute() will be not possible to get messages from my exe

    With the function ShellExecuteEx() its only possible to get this informations:
    ERROR_FILE_NOT_FOUND
    ERROR_PATH_NOT_FOUND
    but not from my exe

    Should i change my strategy? And no use ShellExecute?
    Think DigitalGasoline

  7. #7
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: how to get error or informations from a exe under dos?

    Well, I'm not really a WinAPI expert but just by taking a quick look at ShellExecute() documentation I can say that CreateProcess() and GetExitCodeProcess() might be a very good alternative for you since you are not really performing an abstract operation on a file in the sense that you want to let the explorer to choose a suitable application to do that, but you rather want to start a process with that specific application.
    J-P Nurmi

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

    Default Re: how to get error or informations from a exe under dos?

    Hi,

    if i have understand with CreateProcess Funktion im not able to run my tool in hide modus

    You mean that i could use GetExitCodeProcess() to get information from my exe by using my code?

    U mean it will work?

    I am new and it would be great if i could find a example
    Think DigitalGasoline

  9. #9
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: how to get error or informations from a exe under dos?

    Quote Originally Posted by raphaelf View Post
    if i have understand with CreateProcess Funktion im not able to run my tool in hide modus
    Back to reading MSDN... CreateProcess() takes a "startup info" structure. You can pass SW_HIDE within that structure.

    Quote Originally Posted by raphaelf View Post
    You mean that i could use GetExitCodeProcess() to get information from my exe by using my code?
    Whose code if not yours? Once again, lookup the MSDN...! It is clearly explained there what this function does.

    Quote Originally Posted by MSDN
    If the process has not terminted and the function succeeds, the status returned is STILL_ACTIVE. If the process has terminated and the function succeeds, the status returned is one of the following values:

    • The exit value specified in the ExitProcess or TerminateProcess function.
    • The return value from the main or WinMain function of the process.
    • The exception value for an unhandled exception that caused the process to terminate.
    Quote Originally Posted by raphaelf View Post
    U mean it will work?
    I haven't tried it and I'm not even going to. I'm just giving you some hints. You should try it.

    Quote Originally Posted by raphaelf View Post
    I am new and it would be great if i could find a example
    First of all, focus on reading the function and parameter descriptions from MSDN. Also make sure to follow links to structure descriptions of complex parameters. If still in doubt, doing a Google search on the function name might give surprising results...
    J-P Nurmi

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

    Default Re: how to get error or informations from a exe under dos?

    Hi JPN,

    i changed my strategy..

    i will read information from dos and put it in a file. After i will put this informations to a messagebox for example..

    Thank u
    Think DigitalGasoline

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.