Results 1 to 3 of 3

Thread: How to Send a command to already running process

  1. #1
    Join Date
    Jan 2017
    Posts
    2
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Windows Android

    Default How to Send a command to already running process

    Hello,

    I have started a cmd.exe. with some arguments.
    After starting of the Qprocess , i want to send another argument to the same process.
    QProcess *qProc = new QProcess;
    qProc->start("cmd.exe",QStringList()<<"/C"<<"C:\\setenv.bat");
    Now how to send one more command after the above command to qProc?

    Thanks in advance.

  2. #2
    Join Date
    Dec 2009
    Location
    New Orleans, Louisiana
    Posts
    791
    Thanks
    13
    Thanked 153 Times in 150 Posts
    Qt products
    Qt5
    Platforms
    MacOS X

    Default Re: How to Send a command to already running process

    Hi, I don't think you can do what you want. When you run cmd.exe with args "/C" and "C:\\setenv.bat", it will execute the command c:\setenv.bat and then exit. You can run another cmd.exe via QProcess, but it will be a new process and won't inherit any of the environmental variables you set in c:\setenv.bat.

    You could, however, run a batch file that sets environment variables *and* execute whatever other commands you want in one QProcess invocation.
    I write the best type of code possible, code that I want to write, not code that someone tells me to write!

  3. #3
    Join Date
    Jan 2017
    Posts
    2
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Windows Android

    Default Re: How to Send a command to already running process

    Hi Jefftee,

    Thanks for your answer. Let me try your solution.

Similar Threads

  1. How to command other process?
    By Momergil in forum Qt Programming
    Replies: 10
    Last Post: 30th June 2012, 06:11
  2. How to send SIGINT to a process?
    By SYR in forum Qt Programming
    Replies: 1
    Last Post: 4th March 2011, 08:23
  3. Command in process does'nt work
    By mourad in forum Qt Programming
    Replies: 2
    Last Post: 2nd June 2009, 09:12
  4. Send a key to process
    By Nyphel in forum Qt Programming
    Replies: 2
    Last Post: 9th July 2007, 17:37
  5. When I send a command in QT
    By espariz in forum Newbie
    Replies: 1
    Last Post: 20th June 2006, 20:15

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.