Stefan
Stefan

Reputation: 41

Install Python with Inno Setup

I am creating a setup from C# program successfully with Inno Setup. To run this program I need Python. Until today I asked my customers to install Python manually, since some customers are not always following my installation guide, I am getting often questions from them. Now I want to simplify the installation, so that everything is done automatically. I need to set:

  1. Install path of Python: C:\Python\Python3.5.2
  2. Installation for all users
  3. Set the global environment variable for Python C:\Python\Python3.5.2
  4. If all this already exist no installation needed

I tried to do this with this code, but I didn't had any success. Normal Python installation is starting unfortunately.

[Run]
Filename: "{app}\deploy\python-3.5.2.exe"; \
    Parameters: "/i ""C:\Python\Python-3.5.2"" /qb! ALLUSER=1 ADDLOCAL=ALL"; \
    WorkingDir: "{app}\deploy"; Flags: 32bit; Check: python_is_installed

[Code]

function python_is_installed() : Boolean;
var
  key : string;
begin
   { check registry }
   key := 'software\Python\Python-3.5.2\InstallPath';
   Result := not RegValueExists(HKEY_LOCAL_MACHINE, Key, '');  
end;

What do I do wrong?

BR Stefan

Upvotes: 3

Views: 3467

Answers (2)

Georg W.
Georg W.

Reputation: 1356

Another problem is that the installation check in the code section is not working as expected. RegValueExists() always returns false with an empty value name. That means your check function always returns false even if the key exists. This is the reason why Python installation is run always, even if Python is already installed.

To check for the existence of a key, not a value, use the function RegKeyExists().

See How to check if specific Python version is installed in Inno Setup?

Upvotes: 1

Martin Prikryl
Martin Prikryl

Reputation: 202642

You seem to be using a completely wrong sent of command line arguments (for Windows Installer?).

See Python documentation for correct command-line arguments of the Python Windows installer:
https://docs.python.org/3/using/windows.html


You probably want something like this:

/passive InstallAllUsers=1 TargetDir=C:\Python\Python3.5.2 PrependPath=1

Upvotes: 1

Related Questions