Windows Intune App Failing To Install

In this post, I ran into a weird issue where an app failed to install even though I didn't make any changes. Here I run through the troubleshooting steps, and how to fix it.

Windows Intune App Failing To Install

I have been working a lot with Autopilot and Intune recently, and one of the applications that I had been trying to deploy so that users could install it via the Company Portal app had suddenly started to fail to install on my test Virtual Machine, and I hadn't made any changes to the application. Here is what I did to resolve the issue.

The first thing I did was grab a copy the Configuration Manager Trace Log Tool from an existing SCCM deployment I had - it isn't really required, but it certainly makes it easier to view Intune logs on a local machine when trying to find failures! The next was to find the location of the Intune logs so that we can try and find the cause of the issue, and these are tucked away at: C:\ProgramData\Microsoft\IntuneManagementExtension\Logs. Hopefully, you should see something like this:

The file you need is the IntuneManagementExtension.log. Upon opening the log, I could see errors straight away:

Which was showing the following error message:

[Win32App] folder C:\WINDOWS\IMECache\e0dadaad-e37d-49e2-a3a0-dbadb7ded7a9_22 is failed to delete, marking it as pending delete until reboot. ex = System.IO.IOException: The process cannot access the file 'C:\WINDOWS\IMECache\e0dadaad-e37d-49e2-a3a0-dbadb7ded7a9_22' because it is being used by another process.
   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.IO.Directory.DeleteHelper(String fullPath, String userPath, Boolean recursive, Boolean throwOnTopLevelDirectoryNotFound, WIN32_FIND_DATA& data)
   at System.IO.Directory.Delete(String fullPath, String userPath, Boolean recursive, Boolean checkHost)
   at Microsoft.Management.Clients.IntuneManagementExtension.Win32AppPlugIn.CacheManager.CleanUpStagedContentForApp(Guid appId, Int32 appVersion)

Strange 🤔... The Intune Management Engine is complaining that it cannot delete a folder in the local Intune cache. So the first thing I did was reboot the VM, and then I attempted to install the app again from the company portal, which again just instantly failed and the logs were saying the same message. So this time, I stopped the Microsoft Intune Management Extension service, and attempted to manually delete it from the command line which also failed saying that it was in use by another process:

So something else is using the process! After some digging, I find within Resource Monitor that dism.exe had a lock on the folder. You can search for the path within the CPU | Associated Handles section:

I then killed off the dism process, and then voila! I could then delete the folder from the command line:

Yes at last 🥳! I could then install the application from the company portal without any issues. But what was causing it? Well, one of my Windows apps does a bunch of custom configuration on the workstation to "Italikify" it, and one of the tasks is to install .NET framework 3.5 using a dism command:

dism /online /enable-feature /featurename:NetFX3 /ALL

For some reason (and it literally only just started doing this) the dism command was hanging on systems where it was already installed, instead of it just completing because it was already installed. I am not really too sure why it was hanging unfortunately. To workaround this issue, I found a way of detecting if .NET 3.5 is installed, and to skip the dism command if it is. This is what I did to resolve the issue:

    $key = "HKLM:\SOFTWARE\Microsoft\NET Framework Setup\NDP\v3.5"
    $value = (Get-ItemProperty -Path $key -Name Install).Install

    if ($value -eq 1) {
        LogScreen ".NET framework 3.5 is already installed - skipping"
    } else {
        LogScreen "Installing .NET framework 3.5"
        dism /online /enable-feature /featurename:NetFX3 /ALL
    }