3

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

0

2 Answers 2

1

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
Sign up to request clarification or add additional context in comments.

Comments

1

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?

1 Comment

The RegValueExists(Root, Key, '') checks for an existence of the default value in the key. I do not have that specific Python version installed. But checking the versions I do have installed, they indeed have the default value in their InstallPath subkeys. So it's quite possible that OP's code works in that particular respect. Otherwise, your code seems better in respect to testing Python installation. But I still believe you are not answering OP's question. Consider starting a new question about detecting Python installation and self-answer it. I'll be happy to upvote your posts then.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.