hsc
Posts: 71
Joined: Wed Mar 02, 2016 2:55 pm

Installer command line

Fri Oct 07, 2022 8:08 am

Hi,

I created an installer (*.exe with everything inside one file) with AI 19.9. It runs fine when I double click the resulting exe file. Now I want to create automated tests for the installer. This requires launching the installer from the command line with no UI interaction. I want to test new install, upgrade install, and uninstall. I will use the "/qn" (no UI) and the "/L*V" (verbose logging) switches. I am aware that the installer must run elevated.

I expect the following outcomes of my test:
  • If the product isn't installed yet, an upgrade install should fail, and so should uninstall, but fresh install should succeed.
  • If an older version is installed, upgrade and uninstall should succeed, but fresh install should fail.
  • If a younger version is installed, upgrade and fresh install should fail, but uninstall should succeed.
I tried finding hints for command line switches that force a fresh or update install, or an uninstall operation. There is some contradictory(seemingly, at least) information available like the "/upgrdinst" and "/upgrade" switches, but when I use any of them (like "MyInstaller.exe /update"), I get the message "Invalid command line".

Thank you for additional information.

Hans

Catalin
Posts: 6537
Joined: Wed Jun 13, 2018 7:49 am

Re: Installer command line

Mon Oct 10, 2022 3:16 pm

Hello Hans,

In order to upgrade an installed instance, you should use the /upgrdinst command option, as described here:

How do I install multiple instances from the command line?
but when I use any of them (like "MyInstaller.exe /update"), I get the message "Invalid command line".
You get this message because there is not such command as "/update", as far as I know.

Hope this helps!

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

hsc
Posts: 71
Joined: Wed Mar 02, 2016 2:55 pm

Re: Installer command line

Tue Oct 11, 2022 8:54 am

Hello Catalin,

thank you for your reply -- /upgrdinst doesn't work either.
This is what I did:
  • Installed an older version of the product.
  • From an elevated command prompt, I launched this command line for the current version of the product:
    MyInstaller.exe /L*V installer.log /upgrdinst
After some moments, I received the message "Invalid command line".
The log file is 1289 lines long, but not knowing what to look for, it is hard to find out what's going on. However, I find this line:
Doing action: INSTALL

Cheers
Hans

Catalin
Posts: 6537
Joined: Wed Jun 13, 2018 7:49 am

Re: Installer command line

Tue Oct 11, 2022 2:47 pm

Hello Hans,

As you can see in the article I've previously mentioned, you also need to pass the ProductCode of the instance, e.g.:

Code: Select all

YourSetup.exe /upgrdinst <instance_product_code>
e.g. of a ProductCode:

Code: Select all

{02484BC7-8E53-443E-870A-8EEAB3CD4732}
Hope that helps!

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

hsc
Posts: 71
Joined: Wed Mar 02, 2016 2:55 pm

Re: Installer command line

Wed Oct 12, 2022 7:34 am

Hi Catalin, and thanks again for your assistance. It still doesn't work for me.

- When I use the command switches "/L*V log.txt /upgrdinst {productcode}", I still get the message "invalid command line".
- When I omit the /L switch, the installer starts to work and the reports "This action is only valid for products that are currently installed."
I tried using all GUIDs which AI displays in "Product Details -> Product IDs", with the same resulting message.
Running out of options...

Best regards
Hans

Catalin
Posts: 6537
Joined: Wed Jun 13, 2018 7:49 am

Re: Installer command line

Thu Oct 13, 2022 2:55 pm

Hello Hans,

You are always welcome and sorry we haven't gotten this resolved just yet.

To be honest with you, I'm a bit confused about your scenario. Are you using "Multiple Instances" in your project?

The first thread made me think so, but after reading the next ones, I'm not so sure anymore, especially after this:
I tried using all GUIDs which AI displays in "Product Details -> Product IDs", with the same resulting message.
as the GUID of the instance is presented in the "Multiple Instances" page, e.g.:
Screenshot_14.png
Screenshot_14.png (95.95KiB)Viewed 8529 times

Could you please confirm you are using this feature?

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

hsc
Posts: 71
Joined: Wed Mar 02, 2016 2:55 pm

Re: Installer command line

Fri Oct 14, 2022 8:34 am

Hello Catalin,

sorry but I am not using the "multiple instance" feature.

To give you a full picture of what I want to achieve:

I am planning to create automated tests for the installer. The installer is a single exe file which, when run interactively, should start with a language selection dialog. The relevant scenario for the automated test is "unattended install" with the "/qn" switch so that no dialogs pop up. I know how to check whether the product is already installed on a machine, and which version of it, by querying the registry. By checking before and after running the installer, I can verify that the correct operation occurred. After successfully installing or updating, I start a test suite for the application.

When I interactively start the installer, it runs either an install or an upgrade operation, depending on whether or not an older version is already installed; if the same version is installed, I have the choice of modify, repair or remove operations. This is obviously not the same in a silent scenario. I imagine to control this behaviour by command line options, like "/install", "/upgrade", "/repair" (not relevant in this scenario) and "/remove".

I'm trying not to put too much into this conversation... just this: I found the page https://www.advancedinstaller.com/user- ... -file.html which lists (among others) the command line switches "/newinst <instance_id>" and "/upgrdinst <instance_product_code>" which go into the right direction (uninstall missing) but I don't see how to get <instance_id> or <instance_product_code>.

Side note: The command line "C:\Setup.exe /x // /l*v install.log" (from an example on that page) yields the same message: "Invalid command line".

Best regards
Hans

Catalin
Posts: 6537
Joined: Wed Jun 13, 2018 7:49 am

Re: Installer command line

Fri Oct 14, 2022 1:58 pm

Hello Hans,

Thank you for your followup on this.

I thought you were using that support. Now that we are "on the same page", let's review your requirements once again.

Let's start with two definitions here, so we can better understand why and why not some of your expectations can be met.

An update can be of two types:

- a patch

- a major upgrade

1. A patch is basically a diff between two setup packages, say A and B.

If package A contains the file A.TXT and backage B contains both A.TXT and B.TXT, the patch will only contain B.TXT (the diff between the two).

A major advantage of the patch is its size. As you can imagine, just by containing the B.TXT file, it is much smaller in size.

A big disadvantage of the patch file is that it can not be installed on its own. It will always require the previous version to be installed.

In our case, package A will always need to be installed. Upon applying the patch on that, we will obtain package B.

A more technical explanation of this would be that the patch only contains the differences between the two MSIs tables. As you may already know, an MSI is basically a database. When the patch is applied, the base MSI (package A) is merged with the patch and this is how we obtain package B.

2. A major upgrade, on the other hand, is an independent package. This will automatically uninstall the previous version and then install the newer version. In case the previous version does not exist on the machine, the package will be treated as a first time installation.

As you can see above (what I've highlighted), a major advantage of the upgrade is that it can be both an upgrade and a first-time installation, unlike the patch which can only be installed if the previous version is already installed.

And, of course, a disadvantage is its size, which is higher than the one of the patch.

Hopefully now we have a better grasp of what each of these terms mean. Let's try to go over your requirements once again and see what and what's not possible:
If the product isn't installed yet, an upgrade install should fail, and so should uninstall, but fresh install should succeed.
This is, as explained earlier, unfortunately, not possible. If the product is NOT installed, then the upgrade will be treated as a first-time installation and therefore succeed.
If an older version is installed, upgrade and uninstall should succeed, but fresh install should fail.
This is, if I understood correctly what you mean, the default behavior of Windows Installer.

For instance, if we have v1.0.0 installed and we install v2.0.0 it will upgrade v1.0.0. The normal uninstall of v1.0.0 will also work as expected.

Regarding the fresh install, this will not work. If you launch the same setup, it will automatically enter Maintenance Mode (giving the user the options to repair/remove the product).
If a younger version is installed, upgrade and fresh install should fail, but uninstall should succeed.
On a machine, if we have v2.0.0 installed and we try to install v1.0.0, it will not work. This is the default behavior of Windows Installer.

Regarding the fresh installation, as previously explained, if v2.0.0 is already installed and we launch again v2.0.0, we will enter the Maintenance Mode.

The uninstall, of course, will succeed (there is no reason why it shouldn't).
I'm trying not to put too much into this conversation... just this: I found the page https://www.advancedinstaller.com/user- ... -file.html which lists (among others) the command line switches "/newinst <instance_id>" and "/upgrdinst <instance_product_code>" which go into the right direction (uninstall missing) but I don't see how to get <instance_id> or <instance_product_code>.
This refers to the "Multiple Instances" support which you are not using, so we can safely ignore this.

Now, the thing is, although I understand the logic behind your requirements, I'm not quite sure they are achievable.

The main reason for this is that Windows Installer handles this in an automatic manner - you do not have to manually specify that an installation is an upgrade or a fresh installation. The Windows Installer will automatically detect these.

If you have any other questions, please let me know and I will gladly assist.

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

hsc
Posts: 71
Joined: Wed Mar 02, 2016 2:55 pm

Re: Installer command line

Fri Oct 14, 2022 2:18 pm

Hi Catalin,

thank you for the detailed explanation! Now I understand better. I'll have to redesign the test, which is not much of a problem since I haven't implemented it yet.

We are creating installers of the type which you call a "major upgrade" - they can be used for a fresh install or an upgrade.

Am I right to assume I cannot use the command line to uninstall? I believe I saw another way to achieve that, somewhere on the internet... I'll dig that out next week.

Best
Hans

Catalin
Posts: 6537
Joined: Wed Jun 13, 2018 7:49 am

Re: Installer command line

Fri Oct 14, 2022 3:51 pm

You are always welcome, Hans!

I am glad to hear everything is clearer now and, as always, my pleasure to assist.
Am I right to assume I cannot use the command line to uninstall? I believe I saw another way to achieve that, somewhere on the internet... I'll dig that out next week.
It is possible to uninstall from the command line.

If you have an MSI package, you can uninstall as it follows:

Code: Select all

msiexec /x "<path_to_msi>"
and if you have an EXE package:

Code: Select all

setup.exe /x //
where "//" means we pass the "/x" command to the MSI.
Screenshot_15.png
Screenshot_15.png (31.39KiB)Viewed 8304 times

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

hsc
Posts: 71
Joined: Wed Mar 02, 2016 2:55 pm

Re: Installer command line

Mon Oct 17, 2022 2:30 pm

Hi Catalin,

thank you for following up. When I tried it today, it worked, and I don't know what I did different last week. Maybe the order of command line options matters? Anyway, problem solved and I'll have to think about how to design the test.

Best
Hans

Catalin
Posts: 6537
Joined: Wed Jun 13, 2018 7:49 am

Re: Installer command line

Mon Oct 17, 2022 2:57 pm

You are always welcome, Hans!

Glad to hear everything is working as expected now. :)

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Common Problems”