I am on Windows and in my Inno setup installer I use exec command twice inside separate functions: inside the first one (which is called right at the beginning of the script and I am sure that it works correctly) I install Python:
Exec(ExpandConstant('{app}\python-3.7.4.exe'), '', '', SW_SHOWNORMAL, ewWaitUntilTerminated, ResultCode)
and inside the second function (which is called in CurStepChanged ssPostInstall step some time after the first function call) I call a script using exec, which is dependent on Python:
Exec('{#Some_Dir}\python-tools\migrate_db.bat', '', '', SW_SHOWNORMAL, ewWaitUntilTerminated, ResultCode)
This second script returns an error of no Python is installed. It behaves like its CMD window was opened before Python installation. Restarting Inno setup installer and skipping the first function makes the second script run correctly.
Why? So I am thinking about something like forcing Inno setup to open completely new CMD window for the second script. Is it possible?
EDIT
The question is not about how does Windows command processor search for commands and why "X is not recognized as an internal or external command...". The question is about how described thing happens in Inno setup when two separate exec commands are called after each other.