Results 1 to 12 of 12

Thread: Start a exe file with parameters

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

    Red face Start a exe file with parameters

    Hello Everybody,

    i am using a exe file to push some software to clients..

    now i am using a bat file with some parameters like:

    psexec.exe \\hostname -u etrust - p etrust01 \\hostname\c$\notes.exe

    My question: its possible to run this exe with my parameters without uing a bat file or dos?

    If yes it would be very nice..

    Thnanks a lot for a answer

    Im trying like this:
    Qt Code:
    1. void MainWindow::startpsexec()
    2. {
    3.  
    4. list << "\\\\stchps426 " << "-u " << "etrust " << "-p " << "etrust01 " << "-i " << "\\\\stchps426\\c$\\notes.exe";
    5.  
    6. QProcess process;
    7. process.execute("psexec.exe", list);
    To copy to clipboard, switch view to plain text mode 
    but is not working
    Last edited by raphaelf; 16th June 2008 at 10:15.
    Think DigitalGasoline

  2. #2
    Join Date
    Jun 2007
    Location
    India/Bangalore
    Posts
    156
    Thanks
    26
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Thumbs up Re: Start a exe file with parameters

    Qt Code:
    1. list << "\\\\stchps426 " << "-u " << "etrust " << "-p " << "etrust01 " << "-i " << "\\\\stchps426\\c$\\notes.exe";
    2.  
    3. QProcess process
    4.  
    5. process.execute("psexec.exe", list);
    To copy to clipboard, switch view to plain text mode 
    Try this ,

    Qt Code:
    1. QProcess *process = new QProcess(this);
    2.  
    3. process->start("psexec.exe \\hostname -u etrust - p etrust01 \\hostname\c$\notes.exe");
    To copy to clipboard, switch view to plain text mode 
    Thanks,
    Rajesh.S

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

    Default Re: Start a exe file with parameters

    Hi

    this is not working:
    Qt Code:
    1. QProcess *process = new QProcess(this);
    2. process->start("psexec.exe \\stchps426 -u etrust -p etrust01 -i \\stchps426\c$\notes.exe");
    To copy to clipboard, switch view to plain text mode 

    but if i open a dos window and write this it works:
    Qt Code:
    1. psexec.exe \\stchps426 -u etrust -p etrust01 -i \\stchps426\c$\notes.exe
    To copy to clipboard, switch view to plain text mode 

    Why is not working?

    im running winxp and qt 4
    Think DigitalGasoline

  4. #4
    Join Date
    Jun 2007
    Location
    India/Bangalore
    Posts
    156
    Thanks
    26
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Thumbs up Re: Start a exe file with parameters

    are u geting any error ?

    or

    what's happening when u execute this code?
    Thanks,
    Rajesh.S

  5. #5
    Join Date
    Jun 2007
    Location
    India/Bangalore
    Posts
    156
    Thanks
    26
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Thumbs up Re: Start a exe file with parameters

    If this is running through command prompt try this

    Qt Code:
    1. QProcess *process = new QProcess(this);
    2.  
    3. process->start("cmd /C psexec.exe \\hostname -u etrust - p etrust01 \\hostname\c$\notes.exe");
    To copy to clipboard, switch view to plain text mode 
    __
    Regards,
    Rajesh.S
    Thanks,
    Rajesh.S

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

    Unhappy Re: Start a exe file with parameters

    Hi,

    i get no error.

    if i run this it happens notthing:
    Qt Code:
    1. QProcess *process = new QProcess(this);
    2. process->start("psexec.exe \\stchps426 -u etrust -p etrust01 -i \\stchps426\c$\notes.exe");
    To copy to clipboard, switch view to plain text mode 

    If i run this, i it happens nothing:
    Qt Code:
    1. process->start("cmd /C psexec.exe \\hostname -u etrust - p etrust01 \\hostname\c$\notes.exe");
    To copy to clipboard, switch view to plain text mode 

    If i run this i can see in task manager that psexec run quick:
    Qt Code:
    1. ..
    2. process->start("psexec.exe");
    3.  
    4. I dont know what to do now
    To copy to clipboard, switch view to plain text mode 
    Think DigitalGasoline

  7. #7
    Join Date
    Apr 2006
    Location
    Minsk, Belarus
    Posts
    33
    Thanks
    2
    Thanked 6 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Start a exe file with parameters

    Instead of

    "psexec.exe \\stchps426 -u etrust -p etrust01 -i \\stchps426\c$\notes.exe"

    try

    "psexec.exe \\\\stchps426 -u etrust -p etrust01 -i \\\\stchps426\\c$\\notes.exe"

    And you may use static method QProcess::startDetached() instead of QProcess::start(). This does not require QProcess object creation.

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

    Smile Re: Start a exe file with parameters

    It works now..

    but its not possible to run this psexec.exe in hide modus?
    Because when i start psexec a dos window opens..

    Its possible to hide this?

    great job thanks forwarding
    Think DigitalGasoline

  9. #9
    Join Date
    Apr 2006
    Location
    Minsk, Belarus
    Posts
    33
    Thanks
    2
    Thanked 6 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Start a exe file with parameters

    Quote Originally Posted by raphaelf View Post
    but its not possible to run this psexec.exe in hide modus?
    Because when i start psexec a dos window opens..

    Its possible to hide this?
    Qt Code:
    1. QString exePath = "psexec.exe";
    2. QString arguments = "\\\\stchps426 -u etrust -p etrust01 -i \\\\stchps426\\c$\\notes.exe";
    3. #ifdef Q_OS_WIN32
    4. ShellExecuteW(NULL, NULL, (LPCWSTR)exePath.toStdWString().data(), (LPCWSTR)arguments.toStdWString().data(), NULL, SW_HIDE);
    5. #endif
    To copy to clipboard, switch view to plain text mode 


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

    Default Re: Start a exe file with parameters

    I get error on compiling:

    LPCWSTR, SW_HIDE and ShellExecuteW undeclared
    Last edited by raphaelf; 16th June 2008 at 15:41.
    Think DigitalGasoline

  11. #11
    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: Start a exe file with parameters

    Quote Originally Posted by raphaelf View Post
    I get error on compiling:

    LPCWSTR, SW_HIDE and ShellExecuteW undeclared
    So include the <windows.h> (or <qt_windows.h>) header. If that's not enough, then lookup ShellExecute on MSDN to see which header file to include.
    J-P Nurmi

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

    Thumbs up Re: Start a exe file with parameters

    Hi All,

    THANK YOU VERY MUCH!!!

    SOLVED!!!
    Think DigitalGasoline

Similar Threads

  1. QtHelp Module - registering compressed help file gives error
    By Ankitha Varsha in forum Qt Programming
    Replies: 1
    Last Post: 16th May 2008, 14:14
  2. Set up the Qt4.3.2 with Visual Studio 2005
    By lamoda in forum Installation and Deployment
    Replies: 6
    Last Post: 30th January 2008, 06:51
  3. file renaming on windows
    By jdd81 in forum Qt Programming
    Replies: 9
    Last Post: 2nd October 2007, 19:41
  4. qt-3.3.8 fail in scratchbox
    By nass in forum Installation and Deployment
    Replies: 0
    Last Post: 25th May 2007, 15:21
  5. Replies: 2
    Last Post: 27th March 2007, 12:09

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.