1
votes

I am currently working on an already existing installer made with Inno Setup and I am trying to add a Cancel button that would allow the user to cancel a .bat (batch file) execution.

For the moment the behaviour is as follow:

The user can click on "Start button" to run the .bat file (it runs with SW_HIDE flag). Then a result of the .bat is parsed and is shown in the window.

The problem is that the .bat execution is quite long and the user might want to cancel it. However, during the run of this .bat, it is not possible to click anywhere.

Do you have any tips?

1

1 Answers

1
votes

This is not an easy task. What makes your question pretty broad.

I'll give you basic steps you need to do:

  • Execute the batch file with ewNoWait, so that you do not block the Inno Setup GUI.
  • Disable Inno Setup window controls, while the batch file is running, to prevent user from doing anything meanwhile.
  • Create a timer that will keep checking if the batch file finished. You can for example have the batch file create some file in a temporary folder to indicate it finished.
  • Have a button to cancel the batch file. If the batch file can cancel itself, it's easy. Again, you can have the installer create a file to indicate to the batch file it should cancel. If you need to kill the batch file forcefully, you need a process ID. That's more difficult.

If you need details on individual steps, ask specific questions on these. And provide more details where needed (like where and how the the "Start" button is located/implemented, how the the batch file works and how it can be cancelled).