This blog is about updating an application which you can not update through automation like Chocolately and/or PatchMyPC. I am going to update an application via Win32App in Microsoft Intune. I am deploying this using a script which first uninstalls the old version and then installs the new one. The application that I am going to update is SmartLockr.
Prerequisites
We need to create a couple of files

The first file is the installer for the latest version of Smartlockr of your line of business application.
The second file is a Powershell Script. This is the syntax:
$SmartlockrGUID = Get-WmiObject win32_Product if ($SmartlockrGUID.identifyingnumber -match "{D6F8DEFE-10D0-4C29-A31B-589A1A49BAC9}") { msiexec.exe /X "{D6F8DEFE-10D0-4C29-A31B-589A1A49BAC9}" /qn /norestart } #Start Sleep For Removing Application Start-Sleep -Seconds 30 if ($SmartlockrGUID.identifyingnumber -notmatch "{21A826BB-6190-4A70-9B35-7C15C4986D2C}") { msiexec.exe /I "C:\ProgramData\AutoPilot\SmartLockr\SmartLockr for Outlook 4.5.051220.2-all-users.msi" /qn /norestart } #Start Sleep for installing Application Start-Sleep -Seconds 30
The script needs some explanation. The first line collects all the applications installed on your machine, for example:

This information is stored in an array called $SmartLockrGUID.
In the second part of the script we are going to search the installed application and check if the GUID of the old version of Smartlockr is installed. After that we going to uninstall this application:
if ($SmartlockrGUID.identifyingnumber -match "{D6F8DEFE-10D0-4C29-A31B-589A1A49BAC9}") { msiexec.exe /X "{D6F8DEFE-10D0-4C29-A31B-589A1A49BAC9}" /qn /norestart } #Start Sleep For Removing Application Start-Sleep -Seconds 30
You can get this GUID (“{D6F8DEFE-10D0-4C29-A31B-589A1A49BAC9}”) by running the following command:
Get-WMIObject Win32_Product | where-Object name -like "*Smart*"
This will give you the GUID for Smartlockr or your business application:

The last part of the script is going to install the new version of SmartLockr or your business application
if ($SmartlockrGUID.identifyingnumber -notmatch "{21A826BB-6190-4A70-9B35-7C15C4986D2C}") { msiexec.exe /I "C:\ProgramData\AutoPilot\SmartLockr\SmartLockr for Outlook 4.5.051220.2-all-users.msi" /qn /norestart } #Start Sleep for installing Application Start-Sleep -Seconds 30
You can get this GUID the same way you did with the old version and then your output will be this:

Your script is now complete, it is now time to setup the install.cmd CMD file. This file contains this code:
if not exist "C:\ProgramData\AutoPilot\" md "C:\ProgramData\AutoPilot\" if not exist "C:\ProgramData\AutoPilot\SmartLockr" md "C:\ProgramData\AutoPilot\SmartLockr" xcopy "SmartLockr for Outlook 4.3.030420.1-all-users.msi" "C:\ProgramData\AutoPilot\SmartLockr" /Y xcopy "SmartLockrRegKeys.ps1" "C:\ProgramData\AutoPilot\SmartLockr" /Y msiexec.exe /i "C:\ProgramData\AutoPilot\SmartLockr\SmartLockr for Outlook 4.3.030420.1-all-users.msi" /qn /norestart Powershell.exe -Executionpolicy bypass -File "C:\ProgramData\AutoPilot\SmartLockr\SmartLockrRegKeys.ps1"
This .cmd file copies the files and runs the script.
Packaging
We are now going to package this folder to create a .intunewin file. You are going to need the IntuneWinAppTool. You can download this here link.
This is a command line utility:

You will end up with an .intunewin file:

Deployment
The Win32App now need to be deployed.
Log on to the Intune Portal at https://devicemanagement.microsoft.com/
Go to Apps:

After that go to Windows and add an App:

Add a Win32App:

Select app package file and browse to the SmartLockr for Outlook 4.3.030420.1-all-users.intunewin file.

Specify the package information:

Fill in the program information. The uninstall command will be filled for you due to the MSI in the .intunewin file:

Specify requirements:

Configure the detection rules:
Edit: It has been brought to my attention in the comments that the detection method is not correct. Please make sure the version is checked and the update happen accordingly.

At depencies click next.
Assign the application:

And the update is deployed!
References
More Win32App deployments:
Internet Shortcut via Win32App
Chrome Extension via Win32App
Your detection rule detects the current version and Intune will think it’s already installed and do nothing.
Hi John,
That’s true. I need to update this one.
Thanks,
Niels
Need more information about the “install.cmd” CMD files section.
I have no idea why we are creating this file or what it does. i got the powershell working
Hi Rune,
This is an old concept of mine. This is no longer needed.
Take a look at this example:
https://www.nielskok.tech/intune/schedule-powershell-script-intune/
Thanks,
Niels