zucler
Posts: 3
Joined: Thu Dec 30, 2021 5:13 am

Store cmdline arguments to the registry

Thu Dec 30, 2021 5:16 am

Hi all,

I need to store arg0 (the name of the installer file) that is called to launch an AI-built installer into a registry. I know how to install new values to the registry, but am not sure how to reference arg0, can somebody help me?

For example, if my program installer was stored like "c:\Downloads\fooInstaller.exe", then after I launch it, I'd have a new registry key with stored "fooInstaller.exe" or "c:\Downloads\fooInstaller.exe" in it.

Thanks in advance

Liviu
Posts: 1035
Joined: Tue Jul 13, 2021 11:29 am
Contact:  Website

Re: Store cmdline arguments to the registry

Thu Dec 30, 2021 12:22 pm

Hi and welcome to our forums,
For example, if my program installer was stored like "c:\Downloads\fooInstaller.exe", then after I launch it, I'd have a new registry key with stored "fooInstaller.exe" or "c:\Downloads\fooInstaller.exe" in it.
I'm not quite sure if is possible to achieve what you want.

You can for example save the package name using a property and then store it in the registry, for example like this:
output.png
output.png (20.71KiB)Viewed 3289 times
But the users can change the name of the file before launching it, thus the value saved in the registry will be the default one.

I was trying to find a solution for you using a PowerShell script, but unfortunately there is no way to determine the filename after the package is launched. You can determine it only when you launch the package using PowerShell. This is unstable because the users can change the location and the name of the file.

I'm not sure if this helps but you can set properties from the command line and then save them in the registry as in the example below:

Code: Select all

fooInstaller.exe PROP1=test.exe PROP2=test

Hope this helps! Please let us know if you have any other questions.

Best regards,
Liviu
________________________________________
Liviu Sandu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

zucler
Posts: 3
Joined: Thu Dec 30, 2021 5:13 am

Re: Store cmdline arguments to the registry

Mon Jan 03, 2022 4:36 am

Hi Liviu,

Thank you for your reply. Unfortunately, this is not what we are looking for due to the same reasons you've described. We want to bake in a unique identifier for each of our customers and instead of rebuilding the installer for every customer, we were hoping the rename the installer to include that unique ID.

I was hoping this can be done by calling a VB script during installation or something, but it sounds like the name of the installer file can not be passed to the script.

Liviu
Posts: 1035
Joined: Tue Jul 13, 2021 11:29 am
Contact:  Website

Re: Store cmdline arguments to the registry

Mon Jan 03, 2022 10:56 am

Hi,

After further research, I've been able to find the solution for you.

You can use the OriginalDatabase property. The Windows Installer sets the OriginalDatabase property to the path of the installation database used to launch the installation.
More information on the MSFT OriginalDatabase property article.

All you need to do is to create in the "Registry" page a value with that property:
Registry.png
Registry.png (114.94KiB)Viewed 3189 times

Now, after installation the full path of the install package is stored. It also works if you rename the package on the disk.
Reg.png
Reg.png (29.61KiB)Viewed 3189 times

Hope this helps!

Best regards,
Liviu
________________________________________
Liviu Sandu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

zucler
Posts: 3
Joined: Thu Dec 30, 2021 5:13 am

Re: Store cmdline arguments to the registry

Mon Jan 03, 2022 3:15 pm

Thank you Liviu, this is exactly what I needed!

Liviu
Posts: 1035
Joined: Tue Jul 13, 2021 11:29 am
Contact:  Website

Re: Store cmdline arguments to the registry

Mon Jan 03, 2022 4:16 pm

You're welcome!

I'm glad this helped you.

If you have any other questions, please don’t hesitate to contact us.

Best regards,
Liviu
________________________________________
Liviu Sandu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Building Installers”