1

In my Inno Setup script, I need to execute a command that generates temp files that are to be copied in the [Files] section. I have tried the following:

; cd to the directory of the Inno Setup script and execute a python file
#expr Exec('cmd /C "cd /d %cd% & C:\Python34\python.exe run.py"','','',1,SW_HIDE)

This does not seem to execute as I do not see the files created, which can obviously not be included in the installer.

Along the same lines, how would I execute a command when complete to delete these temp files?

Edit I did execute the cmd by hand and validated that it works

steveo225
  • 11,394
  • 16
  • 62
  • 114
  • The problem is that you're passing command line into the first parameter. The [`Exec`](http://www.jrsoftware.org/ispphelp/index.php?topic=exec) function needs them in the second; help says *Second argument may be used to specify command line to execute.*. – TLama Mar 13 '15 at 15:41

1 Answers1

2

It should be:

#expr Exec('cmd.exe', '/C "cd /d %cd% & C:\Python34\python.exe run.py"','',1,SW_HIDE)

The cmd.exe is the process you are executing, the rest are arguments.

Though even better would be to do without cmd.exe as you do not need it actually:

#expr Exec('C:\Python34\python.exe', 'run.py','c:\startupfolder',1,SW_HIDE)

See Inno Setup Preprocessor: Exec.


Though personally, I'd create a batch file that first runs the Python and then runs Inno Setup compiler. It's way easier and more understandable.

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
  • Thanks, that was my problem. The documentation for that method isn't very good, I must have missed something the first time I read it. I agree about the batch script (that was my first attempt), the problem is, I can't convince other developers to break their old habits, so this is easier, even though it is uglier – steveo225 Mar 13 '15 at 15:57
  • I don't think it could have been said anyhow clearer, *First argument specifies the filename of the module to execute*, *Second argument may be used to specify command line to execute*. – TLama Mar 13 '15 at 16:03
  • Its the *specify command line to execute* part. I suppose since I was using the command prompt, the context confused me. I think it would be clearer if it said *command line arguments* – steveo225 Mar 13 '15 at 20:00