We’re moving our forums to a new platform.

You can still browse and search existing topics, but you can no longer create new topics or post replies.

For questions, technical issues, or feature requests, please don’t hesitate to contact our support team at support@advancedinstaller.com.

Thank you for your understanding!

toonetown
Posts: 37
Joined: Wed May 16, 2018 3:46 pm

Windows LTSC/LTSB

Is there a way to detect (and prevent installation) on Windows 10 Long-term Service Channel (LTSC)?
Catalin
Posts: 7853
Joined: Wed Jun 13, 2018 7:49 am

Re: Windows LTSC/LTSB

Hello,

Unfortunately, I am afraid that we do not have predefined support for detecting the WIndows LTSC OS. However, you can achieve this through a custom action.

For instance, you could create a PowerShell script that detects the version (and also fails if the Windows version is LTSC) and then add it to your project as a "Run Inline PowerShell Script" custom action.

After doing so, you can schedule the custom action before the "Search" action group (at the begin of the installation process).

Hope this helps.

All the best,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
toonetown
Posts: 37
Joined: Wed May 16, 2018 3:46 pm

Re: Windows LTSC/LTSB

So - I know pretty much nothing about Powershell...I am able to see that when I run this command:

Code: Select all

gwmi win32_operatingsystem | select OperatingSystemSKU
It returns the value 125 when running on LTSC. How can I translate that into an inline script for use with Advanced Installer?
Catalin
Posts: 7853
Joined: Wed Jun 13, 2018 7:49 am

Re: Windows LTSC/LTSB

Hello,

Indeed, you are right, after some research I could also find out that the returned value must be "125" for LTSC.

First thing we have to do here is to create the PowerShell script. Please let me try to explain a bit here so you can better understand it. First of all, by running the following command:

gwmi win32_operatingsystem | select OperatingSystemSKU

we get the following result:

Code: Select all

OperatingSystemSKU
------------------
                125
Let's say we want to condition something based on the result of the above cmdlet. First thing we would do will be to store the result of the above cmdlet in a variable. This can be done as it follows:

$ossku = gwmi win32_operatingsystem | select OperatingSystemSKU

Basically, if we wanted to condition anything based on that, we would write it as it follows:

if($ossku -eq "125"{
# do something
}


However, that would not work, because the returned type of the above cmdlet is not actually an integer nor a string, so the above comparison is wrong ("-eq "48"). By typing (in the current PowerShell session) the following:

$ossku.GetType()

we would notice that the $ossku is actually a PSCustomObject (PowerShell Custom Object). The correct way to retrieve the "125" value is like this:

$ossku.OperatingSystemSKU

With that being said, our condition should look something as it follows:

if($ossku.OperatingSystemSKU -eq "125"){
# do something
}


Now, in order to fail the installation based on the operating system SKU, we have two ways in which we can proceed:

1. you can implement this in an inline PS script custom action and then, based on the results, we can use our predefined "ErrorMessage" custom action - which displays a message to the user and then aborts the installation (this is the approach that I would recommend).

2. we can do all from above in a single PS script.

Since I would recommend the first approach, I will explain what steps need to be done in order to achieve it.

Now that we have our script ready, it is time to implement it into a custom action. Here is how you can proceed:

- open your project and go to "Custom Actions" page.

- select a "PowerShellScriptInline" custom action and press the "Add custom action with sequence" button which is placed to the right side of the custom action's name.

- now we should schedule this custom action accordingly. Since we want it to execute at the starting point in our installation, we should schedule it before the "Searches" action group - under "Wizard Dialogs Stage". To do so, simply drag and drop it.

- the custom action's content should look something as it follows:

Code: Select all

# Block for declaring the script parameters.
Param()

# Your code goes here.

Add-Type -AssemblyName PresentationFramework

$ossku = gwmi win32_operatingsystem | select OperatingSystemSKU

if($ossku.OperatingSystemSKU -eq "125"){

# here we set the ABORT_INSTALL property to have the value "1" so we can further use it to condition the ErrorMessage custom action.

AI_SetMsiProperty ABORT_INSTALL 1
}
- under the "Dialogs Stage Condition" section, you should uncheck the "Uninstall" and "Maintenance" checkboxes.

This is pretty much all about the PS script custom action. Now it is time to configure the "ErrorMessage" custom action. To do so, simply choose it from the list and then press the "Add custom action with sequence" button which is located to the right side of the custom action's name. After doing so, it is time to schedule it accordingly. The earliest point in time where this custom action can be scheduled is after the "Paths Resolution" action group (under "Wizard Dialogs Stage"). With that being said, simply drag and drop it after the "Paths Resolution" action group.

In the end, the custom actions should be scheduled as it follows:
CA.PNG
CA.PNG (15.06 KiB) Viewed 7151 times
Now that we have scheduled our "ErrorMessage" custom action, the only thing left is to set the message that you want to be shown to the user. Also, this custom action should be scheduled to run only during the installation process (by unchecking the "Uninstall" and "Maintenance" from under the "Dialogs Stage Condition" section).

Hope this helps.

All the best,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
toonetown
Posts: 37
Joined: Wed May 16, 2018 3:46 pm

Re: Windows LTSC/LTSB

Wow! Very detailed and understandable response. Thank you very much!
Catalin
Posts: 7853
Joined: Wed Jun 13, 2018 7:49 am

Re: Windows LTSC/LTSB

You are always welcome.

I am really glad I could help.
:D

Also, as a followup to my last thread, I forgot to mention something: the PowerShell script should be shared between the two stages ("Wizard Dialogs Stage" and "Install Execution Stage"). The reason behind this is because when a silent installation is performed, the "Wizard Dialogs Stage" is skipped, therefore the custom action will not be executed anymore.

In order to share a custom action between the two stages, all you have to do is to hold SHIFT + drag & drop the custom action accordingly.

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

Return to “Building Installers”