none
cmd; start GUI, wait for it to close b4 proceeding RRS feed

  • Question

  • OK, so I am just a batch/cmd person

    I need a command sequence to start ccleaner,wait for it to close and then continue

    (to then run taskkill to kill ccleaner process that remains running after the program window closes).

    start /WAIT does not work!

    I need to 

    --start Ccleaner
    (here's I am using ccleaner; not part of batch)
    (here I exit ccleaner; not part of batch)
    --Kill the ccleaner process that is still running
    --exit the cmd file

    Can't find a way to make the cmd wait for ccleaner to close.

    Help?

    Friday, August 14, 2015 7:58 PM

Answers

  • That's interesting that it's impossible because in playing around with the one I posted above, and putting in echo statements to see what was going on, and changing things here and there, I ended up with the following that works just fine.  It runs the program, then kills its still-active task after I close/terminate/exit the program (window)...

    @echo off
    "C:\Program Files\CCleaner\Ccleaner64.exe"
    taskkill /IM Ccleaner64.exe
    exit

    • Marked as answer by gladiator- Saturday, August 15, 2015 4:19 PM
    Saturday, August 15, 2015 3:41 AM

All replies

  • Not at all an answer to how to do it in a cmd file.

    That (scheduling it) is no solution at all to my question "find a way to make the cmd wait for ccleaner to close."

    So I schedule it to run.  It opens...and sits there doing nothing!  Also, I often run it when I decide it need to, not a clock...like doing things that clutter caches, or whatever. And I do different things with it at different times.

    In short, scheduled running is not the solution and would not work anyway.

    Friday, August 14, 2015 8:20 PM
  • This is not a ccleaner support forum.

    If ccleaner.exe spawns some other executable when it runs, then it makes sense that start /wait is ineffective. If that's the case, then there's not a good way to work around this in a script.

    But this depends on the design and usage of ccleaner.exe. That's not a topic for this form.


    -- Bill Stewart [Bill_Stewart]

    Friday, August 14, 2015 8:25 PM
    Moderator
  • Well indeed it isn't the ccleaner support forum.  I looked at all the forums for where question about CMD FILES (not ccleaner support--that just HAPPENS to be the program I am trying to run; the problem would apply to ANY GUI type program)

    I apologize for offending you.  Can you please tell me where I should have posted--which is the appropriate forum here for for me to post my cmd issue given it is not "Scripting?"

    Friday, August 14, 2015 9:05 PM
  • the problem would apply to ANY GUI type program

    That depends on how the program operates. If the base executable spawns other executables, then start /wait will not work like you expect. In other words: start /wait is not guaranteed to wait for any GUI application. It waits for an executable, but it depends on what that executable does. If that executable spawns another executable and then terminates, then start /wait has no way of knowing that.

    Again: You will need to ask your question of whoever wrote the executable that "isn't working" when you try running start /wait. That's not a question for this form.


    -- Bill Stewart [Bill_Stewart]

    • Proposed as answer by jrv Friday, August 14, 2015 11:22 PM
    Friday, August 14, 2015 9:59 PM
    Moderator
  • Cannot watch for the process to quit because that is exactly what it does NOT do and why I need to do the taskkill after closing the GUI window WHICH DOES NOT KILL THE PROCESS.   Sorry I was not precise with wording,  I want the batch to open the GUI program, me work in the program, me close the program (which does not stop the process), and THEN the next cmd command kill the task.  Hope I got the wording right this time.


    And since this appears to be the wrong place to talk about cmd fles. I'm gone

    Oh, it is not a matter of the program spawning sub processes--it remaining running to "monitor" stuff.  I want to kill the process when I close the program.  Bye.

    • Edited by gladiator- Friday, August 14, 2015 10:25 PM
    Friday, August 14, 2015 10:21 PM
  • "Mostly your request is a result of lack of technical knowledge about how Windows and most computers and programs work."

    Why thank you.

    Friendly place here.  nobody welcome except the "in" crowd.

    In another place, I just now found this. Since I have a " lack of technical knowledge about how Windows and most computers and programs work," I do not know if this will work or not, but surely won't ask here and get slapped down again.

    • Edited by gladiator- Saturday, August 15, 2015 2:38 AM
    Saturday, August 15, 2015 2:31 AM
  • That's interesting that it's impossible because in playing around with the one I posted above, and putting in echo statements to see what was going on, and changing things here and there, I ended up with the following that works just fine.  It runs the program, then kills its still-active task after I close/terminate/exit the program (window)...

    @echo off
    "C:\Program Files\CCleaner\Ccleaner64.exe"
    taskkill /IM Ccleaner64.exe
    exit

    • Marked as answer by gladiator- Saturday, August 15, 2015 4:19 PM
    Saturday, August 15, 2015 3:41 AM
  • This is a good example of how an incorrect and imprecisely worded question only delays the answer.

    Your script will start the application and then forcibly terminate it in the next line. It relies on a Cmd.exe feature that blocks execution of the script until the executable terminates, and then runs taskkill to terminate executables with that name.

    I don't see the point, but whatever works for you.


    -- Bill Stewart [Bill_Stewart]

    Saturday, August 15, 2015 1:05 PM
    Moderator
  • The point?  My original statement was

    "I need a command sequence to start ccleaner, wait for it to close and then continue"

    While that is imprecise (so I am told), it was the best I could state it.  Sorry I am not a technical writer.  But wait...now that I read it again, it =is= perfectly clear.  I needed to (a) start a program (ccleaner), (b) wait for it to close, (c) continue.  So for me, but not for you, it was perfectly clear, and the point is that the last set of simple commands I posted does exactly what I stated as what needed to be done, but I'm just a person with a "lack of technical knowledge about how Windows and most computers and programs work."

    Instead of being told something like "You just need to start the program directly without using the START command; cmd processing will wait for the started program to terminate before continuing,"  I was berated, and told it is impossible to do.

    Postscript:  I HAD tried many things close to that initially, long before posting here, but all attempts I did used the START command (and failed)--and it turns out the secret is to not use START.


    • Edited by gladiator- Saturday, August 15, 2015 1:36 PM
    Saturday, August 15, 2015 1:30 PM
  • Since you have worked out the problem on your own (whatever it is), feel free to mark an answer.

    -- Bill Stewart [Bill_Stewart]

    Saturday, August 15, 2015 3:11 PM
    Moderator