From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Application Auto Updater

Solved!
Go to solution

I've been messing around quite a bit with version control and trying to get the build version into the application itself. I'm surprised to see posts from 10 years ago complaining about a lack of simple "Show Version" function, but the .net solution might work well enough for the client. Still working on a nice solution for the RT but might put a pin in that until I upgrade from Pharlap to Linux.

 

I then stumbled across the installer INI and XML files and realized it might be possible to write a VI that will check the installed application version number against one on a NAS or local server and then prompt the user to update. I got all the pieces working save one. 

1) Get version from server: The ini and XML both contain the Product Upgrade Code and version so you can see what the latest is from there. As well as any other aspects of the install you want to double check. 

2) Check your own version using the .net functions for the exe properties and compare it to the server to see if you should prompt the user to update. 

3) If they want to update, you can launch the Install.exe silently and asynchronously using System Exec.vi and then close LabView (old version) on successfully completion. 

 

The only issue is that the .net version is from exe build while the XML and INI only seem to have the installer build. Even in windows programs, the installed build version is used. I cannot find a way to either A) get the current installed build without doing some very outside of Labview tasks or B) get the exe build from the installer on the server. 

 

I'm debating just focusing on the EXE but that's not a truly robust solution if the new EXE has more dependencies or something. 


Has anyone done anything like this? Anyway to see what exe version the installer will install? Or anyway to quickly get the version that is already installed? Should I just give up on simpler solutions and use registry keys?

 

0 Kudos
Message 1 of 15
(1,799 Views)

If time of execution is not a concern, try wmic via SystemExec. Or run in separate thread asynchronously.

For example: wmic product where "Name like '%NI-VISA Examples%'" get Version

 

UPDATE: Seems wmic is deprecated as of Win 10 21H1. But someone wrote that you can add it in Win 11 manually as optional feature. I can't check it...

Message 2 of 15
(1,790 Views)

I believe this will just get the version of LabView itself, like 2021 SP1, however I'm looking for the version of the installed application. "1.1.52"

Edit: I confirmed that command just comes back with 21.00.49307, which is the LabView version, not the application. And I see what you mean about runtime, it took over 10 minutes to run just from Command Prompt. 

0 Kudos
Message 3 of 15
(1,714 Views)

Hi Furbs,

The "wimc product" command gives you a list of ALL installed applications on the current system. 

 

As you mentioned, you need a version of your custom app.

That's why you need to apply some filters to wmic.

1. "get Version" - display only apps versions in the output.

2. "Name like '%Your application name%'" - display information only about the application whose name contains "Your application name". ("Name like '%NI-VISA Examples%'" was an example).

The combination of these two filters gives you the version of your application. Not the exe version, but the version of the installed application that's generated when the NI installer is created.

 

And yes, wimc execution is quite long (about 1 minute on my machine). You can create a SubVI that calls the wimc command and collects the result into a text file, for example.

Call this SubVI at the start of your main program via "Asynchronous Call and Forget". Check the contents of the generated file after 20 minutes for example and popup something to the user.

 

Of course, if you need to quickly get the version of your application at startup time, you must find another way (registry, etc.).

0 Kudos
Message 4 of 15
(1,694 Views)

UPDATE:

 

To get the version directly from the registry:

1. Find the product upgrade code (from the installer properties or updateInfo.xml) https://knowledge.ni.com/KnowledgeArticleDetails?id=kA00Z0000019Zj8SAE&l=en-US
2. Convert the upgrade code to the format in which it is stored in the registry, according to the message in this topic.

3. Read the name of the key in the section HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UpgradeCodes\ Code from step (2) - there is only one key.

4. Convert the name of the key found in step (3) back to normal view - this will be the ProductId of the current installation.

5. Locate the DisplayVersion key under section HKLM\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{Code from step (4)} - this is the currently installed version.

 

Hope this is what you are looking for...

Message 5 of 15
(1,664 Views)

Thanks for this! I think this put together all the pieces I needed. 

 

A couple of modifications. 

  • Apparently NI doesn't actually install their programs to Microsoft/Windows/CurrentVersion. I didn't find my product code nor update code anywhere there when searching the registry
  • NI's documentation from 2021 doesn't even fully work as the INI does not contain the product code. 

 

Here's what worked for me to manually find. I will write the code and confirm NI can follow these steps later:

  1. Get product code from installer
    1. install.INI under [install.msi] near the bottom
  2. Get current installation information Update Code and Version 
    1. Open Registry Key HKLM\Software\WOW6432Node\National Instruments\Common\Installer\Dependencies\{Product Code}
    2. Read 'UpgradeCode' and 'Version'
  3. Get installation version from installer
    1. Open SupportFiles\UpdateInfo.xml
    2. Parse and scan for the Upgrade Code
    3. Read ProductVersion
  4. Compare and determine update is needed.

FTR: I'm on LabView v21 32 bit for anyone following at home. 

0 Kudos
Message 6 of 15
(1,648 Views)

ProductId will be changed next time you build the installer. But the UpgradeCode remains constant.

Try to reverse first 8 characters of your Upgrade Code and search under HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UpgradeCodes\
Maybe you can find something useful. This applies more to Windows MSI Exec than to LabVIEW.

 

Unfortunately I can't test this on LabVIEW 2021.

Message 7 of 15
(1,642 Views)

Do you see the Product UpgradeCode for NI in the MS Registries that matches what the XML files has in yours? Which version are you using?

 

I'm not sure what you mean by reverse the first 8 but I've searched for the last section of the product code (12 digits) and found nothing in Windows Upgrade Codes. 

 

You're right about the Product Code. Is it possible that just this computer is messed up on the registry for the Upgrade Code? Otherwise I think I'm DOA on trying to get the Product Code to get the Version number...

0 Kudos
Message 8 of 15
(1,568 Views)

You're right, I have to use the Upgrade Code to get the ProductID of the current installation. Unfortunately, that Upgrade Code does not appear anywhere in Installer/UpgradeCodes. I've been searching for the last 12 characters and its no where in my regex except under the ProductID under National Instruments. 

 

I even checked a second computer. 


Can you confirm that you do a see an UpgradeCode for your NI build in that Windows folder? If so, what version of Labview are you on?

0 Kudos
Message 9 of 15
(1,627 Views)

You inspired me that it's possible again so I went ahead and made everything else that would be needed to automatically update your own program. Just add Product ID and everything will work! 

 

I even tried a 

"$Installer = New-Object -ComObject WindowsInstaller.Installer; " in powershell but that requires looking up the Product ID by name, not UpdateCode so it won't work if your application name changes. 

 

See attached. 

0 Kudos
Message 10 of 15
(1,614 Views)