Debugging non-working batch file or command executed from Inno Setup installer

Solution 1:

When you execute a batch file (or any command), its results (or errors) are either not visible at all (particularly when runhidden flag is used) or disappear that quickly that you cannot read them.

In that case, run the command explicitly via cmd.exe (Inno Setup does it implicitly on its own when running batch files), but this time with /K switch instead of a more common /C switch. The /K switch ensures that a console window does not close on its own. And of course, remove the runhidden flag.

So instead of:

[Run] 
Filename: {app}\setup.bat; Parameters: "arguments"

or an equivalent:

[Run] 
Filename: {cmd}; Parameters: "/C """"{app}\setup.bat"" arguments"""

Use:

[Run] 
Filename: {cmd}; Parameters: "/K """"{app}\setup.bat"" arguments"""

Then the console window stays after the setup.bat finishes and you can see eventual errors.

If the batch file starts with common @echo off command that hides the commands being executed, temporarily commenting out this line with rem will help debugging too.

enter image description here

For quoting of arguments in cmd command-line, see:
Correct quoting for cmd.exe for multiple arguments