Run At Startup



  • Hey all,

    I'm wondering if there's a way to run a program WITHIN QT at startup of the qt program? I've searched the internet for awhile now and can't find anything about it.

    What I'm doing. I have a QT program that I've created, but at the top of the program, I want to run the resource monitor inside the program. I need the resource monitor to actually start and show when I run the qt application. Is this possible? Thanks all!



  • You mean the Windows Resource Monitor? I dont think so. Its Part of the OS. There are no Functions to implement it in your own Program. Maybe with C# but i dont know.



  • @Fuel said in Run At Startup:

    You mean the Windows Resource Monitor? I dont think so. Its Part of the OS. There are no Functions to implement it in your own Program. Maybe with C# but i dont know.

    It's not necessarily the windows resource monitor, but another 3rd party resource monitor that shows in just one line on my computer. I would like it to run in the actual program I have created. But yeah, something like that. As stated, I've hunted awhile now online and haven't found anything related to what I'm wanting to do. So I decided to give in and just ask lol.


  • Qt Champions 2016

    Hi
    Maybe i don't understand clearly what you are trying
    but can you just start the other external .exe program using QProcess ?
    When you app starts up.



  • @mrjj said in Run At Startup:

    Hi
    Maybe i don't understand clearly what you are trying
    but can you just start the other external .exe program using QProcess ?
    When you app starts up.

    Yeah, I tried something like this:

        QString program = "C:/resomonitor.exe";
        QStringList arguments;
        arguments << "-style" << "motif";
    
        QProcess *myProcess = new QProcess(parent);
        myProcess->start(program, arguments);
    

    But nothing works. The program still runs with no errors, but nothing happens.


  • Qt Champions 2016

    @Epiales666

    is that a Qt program? (resomonitor.exe)
    the -style suggest it.
    Also if u go to c:\ and click on it , it will run ?

    did you try with other program for test ?
    like notepad.exe



  • @mrjj said in Run At Startup:

    @Epiales666

    is that a Qt program? (resomonitor.exe)
    the -style suggest it.
    Also if u go to c:\ and click on it , it will run ?

    did you try with other program for test ?
    like notepad.exe

    No, it's a 3rd part resource monitor. And yeah, if I go there and click, it runs. I can either put the .exe in C:/ or I can use AHK (autohotkey) to make a file to run it. But either way, I can't get the program to start using Qprocess. I"m sure there's a way to do it, but I haven't found it yet. Thank you!


  • Qt Champions 2016

    @Epiales666
    It normally just works.
    Also, just use notepad.exe did not work either ??

    try this oneliner
    bool ok = QProcess::startDetached("notepad.exe");



  • @mrjj said in Run At Startup:

    bool ok = QProcess::startDetached("notepad.exe");

    Yeah, I get the error

    warning: C4189: 'ok' : local variable is initialized but not referenced

    But it opens notepad.


  • Qt Champions 2016

    @Epiales666
    it is just warning telling we did not use bool ok for anything and that
    is right :)
    ok so now try with

    c:\\resomonitor.exe
    

    if that cannot start, i am guessing on it needs extra dlls that the
    environment inside QProcess is not setup to find.



  • @mrjj said in Run At Startup:

    c:\resomonitor.exe

    Nope, doesn't do anything either :(

    Thank you for taking the time to help m8. I'll keep messing around with it... tytyty


  • Qt Champions 2016

    @Epiales666

    im pretty sure it just needs some extra dlls.
    Did you just take it from its installation folder and
    put alone in c:\ ?
    and u did use 2 backslashes ?

    c:\\xx.exe <-- 2 in code
    

    Is it a public free one i could also download?



  • @mrjj said in Run At Startup:

    @Epiales666

    im pretty sure it just needs some extra dlls.
    Did you just take it from its installation folder and
    put alone in c:\ ?
    and u did use 2 backslashes ?

    c:\\xx.exe <-- 2 in code
    

    Is it a public free one i could also download?

    Okay, here is the actual link to the resource monitor

    QProcess::startDetached("C:\\Program Files (x86)\IObit\Advanced SystemCare Ultimate\Monitor.exe");
    

    And yes, I put a shortcut in C: and also in system 32, so that I could try using it both ways:

    QProcess::startDetached("C:\\Monitor.exe");
    
    QProcess::startDetached("Monitor.exe");
    

    Trying all three above shows no errors, but won't work either :(


  • Qt Champions 2016

    Hi
    I do not think you can just copy monitor alone.
    that is the error. i guess it has dlls in its folder, which are NOT found when running it
    with QProcess since they are in other folder.

    for this line

    QProcess::startDetached("C:\\Program Files (x86)\IObit\Advanced SystemCare Ultimate\Monitor.exe");
    did you escape all slashes ?
    also it might not like the spaces unless you put "" around 
    

    like this

    QProcess::startDetached("\"C:\\Program Files (x86)\\Windows Photo Viewer\\ImagingDevices.exe\"");
    

    this starts the app.



  • @mrjj

    Yeah, I've tried that way as well... my newest attempts are:

    QProcess *process = new QProcess(this);
    QString monitor="\"C:\\Monitor.exe\"";
    process->startDetached(monitor);
    

    AND

    QProcess::startDetached("\"C:\\Program Files (x86)\\IObit\\Advanced SystemCare Ultimate\\Monitor.exe\"");
    

    Neither one of them work either. Grrrrr Your example works fine. It opens correctly... what am I doing wrong?


  • Qt Champions 2016

    @Epiales666
    I guess that Monitor.exe dont like to be started like that :)
    Im not sure what environment QProcess starts with. if copy of default
    or a reduced one. In any case, i think Monitor.exe tried to load something in dont find when started like that.



  • @mrjj said in Run At Startup:

    @Epiales666
    I guess that Monitor.exe dont like to be started like that :)
    Im not sure what environment QProcess starts with. if copy of default
    or a reduced one. In any case, i think Monitor.exe tried to load something in dont find when started like that.

    Yeah, I can do variants of

    QProcess *process = new QProcess(this);
    QString monitor="\"C:\Monitor.exe\"";
    process->startDetached(monitor);
    

    And it will work. Like if I put in the address for internet explorer, it works fine. So does the example you gave me... But it doesn't seem to like Monitor.exe for whatever reason. Frustrating. It shouldn't matter what exe it is. It should open regardless.

    Anyway, thank you for your help. I'll still mess around with other variants and see if I can't get something to work.


  • Qt Champions 2016

    @Epiales666 said in Run At Startup:

    what exe it is. It should open regardless.

    No, that really is not the case.
    if it has some path set in ENVIRONMENT it uses for data or loads dlls directly from subfolder next to exe, it
    wont work as QProcess might not have
    same setup in ENVIRONMENT. ( i dont know if true or false)

    Also if this one
    "Advanced SystemCare Ultimate 10 is a powerful and full-scale software for PC security"
    It might detect it as tampering and hence do not start.



  • @mrjj

    Thank you very much for your help. I'm going to go ahead and classify this topic as solved, since there is no work around to doing what I'd like to do. You were an extremely helpful person. I'll go back and add to your reputation. Thank you much



  • @mrjj

    So you know, I solved the problem by doing the below:

    QDesktopServices::openUrl(QUrl("file:///C:/Program Files (x86)/IObit/Advanced SystemCare Ultimate/Monitor.exe", QUrl::TolerantMode));
    

    Only issue is I don't know how to place it to a particular spot on my system. I have a blank table set inside my program so that I can move it right into that spot and it looks lke it's part of the program lol... so just have to figure out how to move it to x and y position so that it starts there along with the program at startup.

    But wanted to let you know there was a work around to get it to start when system boots. Again, thanks for your help.



  • @mrjj

    So you can see what I'm talking about...

    https://gyazo.com/b225e65df38e57dafea62e680349089c

    See the Ram and CPU at the top? That's the Monitor.exe.... I just either need to move it to x and y position, or somehow place it WITHIN the app so that it shows there...don't know how to do either lol. I used the:

    setGeometry(1510, 30, 10,10);
    

    For the app location, but not sure how to do that one. Thanks!


  • Qt Champions 2016

    @Epiales666
    Hi
    Cool launcher :)
    I think its sadly not possible to embed monitor into your app.
    But you should be able to move it but to control it, i think you need native windows api.

    Update
    Why not get the values your self?
    https://stackoverflow.com/questions/63166/how-to-determine-cpu-and-memory-consumption-from-inside-a-process



  • @Epiales666
    You want to run an external program.
    From your (Qt) app you can cause that program to launch, just like however you run it now without any app.
    You cannot make that other program's windows or whatever be a part of your program's windows, or control its windows, such that it is embedded in your Qt app.



  • @mrjj

    Oh nice. I have that bookmarked. Will definitely think about trying to do that. Thank you!



  • @JNBarchan

    Yeah, I didn't think it possible to embed it into the program. As you read above, we had a problem getting it to even run at all outside the program. I fixed that today thank goodness. And yeah, wouldn't be anyway to even operate it if it were embeded. I just will figure out how to move it 'INTO' the table I have in my program. Or should I say, move it OVER my app to make it appear to be inside it lol. Thanks for taking the time to reply. I really do appreciate it.



  • @Epiales666 said in Run At Startup:

    @JNBarchan

    I just will figure out how to move it 'INTO' the table I have in my program. Or should I say, move it OVER my app to make it appear to be inside it lol.

    That is likely to prove difficult. Since it will only be "over" your app, if, say, your app's window is moved the resource monitor will not move with it. Further, because of the "over" you may find window up-front problems, or when over it may block interaction with your app, depending on how the monitor behaves. You will not find a robust solution this way, just saying.



  • @JNBarchan

    Yeah, I have it always on top for both of them, and it does stay right in the area at the top of my application. It doesn't fall behind it or anything. I set my app to show at the far right top of my screen to be away from anything I"m doing. My internet browser and screen is big enough that I don't have to have it full screen, so I always see my app. It works for me pretty well, as my screen is large enough. I do think, however, I'm going to look into the link that @mrjj posted above, and see about putting them inside the app.



  • @Epiales666
    If it works for you personally that's fine :)

    To avoid separate-process/windows issues, you need either @mrjj 's solution of you write your own (Qt) application to display the data, or you find something like a resource monitor "component" which is for embedding in your code. I would Google for that first.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.