Working with the restart behavior of Win32 apps

A long time ago, I did a post about Working with the restart behavior of Applications in ConfigMgr 2012. That post is still being read pretty well. Based on the interest of that post, and the introduction of nice new features to the Win32 apps, I thought it would be a good idea to redo that post for Microsoft Intune. Before an IT administrator had to be creative to work with, or work around, the restart behavior of Win32 apps. Either by wrapping installations and capturing the exit code, or by tuning the translation of an return code. With the latest adjustments to the Win32 apps, within Microsoft Intune, the IT administrator has more options to actually work with the return code of an Win32 app installation. These configuration options are similar to the configuration options within the app model of ConfigMgr. In this post I’ll discuss the 2 layers that together define the restart behavior after the installation of Win32 apps.

Return codes

When looking at the restart behavior after the installation of Win32 apps, the first thing that should be looked at is the return code after the installation. By default, when adding a Win32 app to Microsoft Intune, a list of standard return codes is added to indicate post-installation behavior (see figure below). These are often used return codes. When the Win32 app installation ends with a different return code, additional entries can be added. This configuration is available via [Win32 app] > Properties > Return codes.

Fore every return code a code type can be configured. The code configures the post-installation behavior of the Win32 app. The following code types are available and can be configured with the return code to apply the mentioned behavior:

  • Failed – The Failed return code indicates that the Win32 app installation failed.
  • Hard reboot – The Hard reboot return code indicates that the device is required to restart to complete the installation. Additional Win32 apps cannot be installed on the device without restart. The user will be notified about the required restart.
  • Soft reboot – The Soft reboot return code indicates that the next Win32 app is allowed to be installed without requiring a restart, but a restart is necessary to complete the installation of the installed Win32 app. The user will be notified about the restart.
  • Retry – The Retry return code indicates that the Win32 app installation is retried three times. The installation will wait for 5 minutes between each attempt.
  • Success – The Success return code indicates the Win32 app installation was successful.

Enforce device restart behavior

The second thing that should be looked at is how the device will react on the configured return code. By default, when adding a Win32 app to Microsoft Intune, the default device restart behavior is set to App install may force a device restart (see figure below). This configuration will make sure that the device will restart after the Win32 app installation, if needed, but still in an acceptable manner. The restart behavior can be configured to respond to return code differently. That configuration is available via [Win32 app] > Properties > Program.

Multiple device restart behavior configurations are available. And all these configuration options have their own effect on the return code of the Win32 app installation. The following device restart behaviors are available and can be configured to apply the mentioned behavior (including a short explanation about the expected behavior):

  • Determine behavior based on return codes: This option means that the device will restart based on the configured return code. With this configuration a Hard reboot return code will immediately trigger a restart of the device and a Soft reboot return code will notify the user that a restart is required to finish the installation.
  • No specific action: This option means that the installation will suppress device restarts during the Win32 app installation of MSI-based apps. Effectively that means that parameters are added to the installation command line of MSI-based apps to suppress device restart. With this configuration any restart will be suppressed.
  • App install may force a device restart: This option means that the Win32 app installation is allowed to complete without suppressing restarts. With this configuration a Hard reboot return code will notify the user that a restart of the device will be triggered in 120 minutes and a Soft reboot return code will notify the user that a restart is required to finish the installation.
  • Intune will force a mandatory device restart: This option means that a successful Win32 app installation will always restart the device. With this configuration any successful return code will immediately trigger a restart of the device.

More information

For more information about the Win32 app functionality in Microsoft Intune, refer to the documentation about Intune Standalone – Win32 app management.

21 thoughts on “Working with the restart behavior of Win32 apps”

  1. Hello,
    I’ve changed the return code type for the return code 0 from Success to soft reboot. On device restart behaviour I use Determine behavior based on return codes. In this way intune notify me that I need a restart to finish the installation of an win32 app.
    The problem is that in intune, the status of the installation remains on Pending, with status details message of “device must be rebooted to c…”
    How can I force Intune to report correctly the status of the installation after the reboot? Thanks!

    Reply
  2. Hello and thanks for this quick reply.
    That was also my hope, that after the next re-evaluation it will be reported correctly in intune, but as I observe, it doesn’t work this way.
    Still trying to figure out how to do it l.

    Reply
    • Hi fcptv,
      When I’m just thinking about it a bit longer, it probably won’t change that status as you’ve assigned that status to the exit code. I think if you want to restart the device after the installation, you shouldn’t play with the behavior of the default exit codes. I think you should look at for example adjusting the exit code after installation.
      Regards, Peter

      Reply
  3. Hi Peter,

    In Autopilot, Have you ever run across the case where an app set to device restart behavior “Intune will force a mandatory device restart” or “Determine behavior based on return codes” (with exit code 1641) will hang the Device ESP process after the reboot. Why? Well, using Get-AutopilotDiagnostics.ps1, I see that the app didn’t update from “2 (Downloading / Installing)” to “3 (Success / Installed, rc = 0)”. Everything else after the reboot installs. I’m looking for a fix (other than don’t reboot during Device ESP!).

    Thanks, Adam

    Reply
    • Hi Adam,
      Sounds like similar behavior as with unexpected restarts like with Defender Application Control. Haven’t seen any real pretty solution yet (except postponing reboot). You might want to reach-out to support for any alternatives and/or reasoning.
      Regards, Peter

      Reply
  4. Hi Peter, you stated that in both Reboot-Configurations “No specific action” and “App install may force a device restart” the Hard-Reset will trigger an automatic reboot 120 Minutes after the installation took place and a soft-reboot will simply inform the user that a reboot is required. Shouldn´t “no specific action” never initate a reboot by itself?
    Regards,
    Holger

    Reply
  5. Hi Peter

    Where do we find these return codes?

    In event viewer or intune logs?

    Or is this basically, when an app installs from intune and you get a successfully installed or failed message etc?

    Reply
  6. Hi Peter. Great web, congrats!

    I want to ask you how prevent that the user close the popup about the reboot when the time is comming?
    I the user closes de popup when the contdown ends the reboot is abrupt without any warning.

    Thanks.

    Tegards

    Reply
  7. This is great and all, but the win32 app I set up notifies me that it needs a restart and then restarted 2 minutes later. It would be nice if Microsoft was more specific on these pages. It definitely wasn’t a 120 minute notify before restart even though I have it set to “App may force a restart.”

    Some of the options are severely lacking as far as Intune app management goes.

    Reply
  8. Hi Peter,

    we have configured the device restart behavior to “determine behavior based on return codes”.
    The Return code 3010 is at default “Soft reboot” and we set the Restart grace period to 30 min. with a countdown at 5 min.

    But we only see the notification about the installation and that we have to restart the computer. There is no countdown dialog box and no restart after the restart grace period.

    Any idea why we don’t get the countdown and the restart?

    Best regards,
    Heino

    Reply
    • A countdown dialog box and a restart after the restart grace period are only available if your application throws a return code 1641(hard reboot).
      The return code 3010 (soft reboot) will just notify the user via Windows notification but will not enforce a reboot.

      Reply
  9. Hi Peter
    So we are trying to provision HPSureAdmin on laptops via Win32App.
    The win32 app contains all the payloads,powershell script and a batch file.

    Batch file (Install.bat)

    SET ThisScriptsDirectory=%~dp0
    SET PowerShellScriptPath=%ThisScriptsDirectory%InstallHPSA.ps1
    PowerShell -NoProfile -ExecutionPolicy Bypass -Command “& ‘%PowerShellScriptPath%'”;

    Powershell Script

    Suspend-BitLocker -MountPoint C: -RebootCount 0
    Set-HPSecurePlatformPayload -PayloadFile EKpayload.txt
    restart-computer -force
    Suspend-BitLocker -MountPoint C: -RebootCount 0
    Set-HPSecurePlatformPayload -PayloadFile SK.txt
    Set-HPSecurePlatformPayload -PayloadFile SAOn.dat
    Set-HPSecurePlatformPayload -PayloadFile LAKPayload.dat
    Resume-BitLocker -MountPoint C:

    The batch file runs and provisions the first payload and first reboot.
    The Win32App never resumes like a SCCM Task sequence does.
    Is there a way to make it continue and complete the process.

    One of the ideas was to split the script and second half is deployed which has dependency on first half(first 3 lines) containing the reboot but I am not sure if that would work..

    Please help

    Reply

Leave a Reply to fcptv Cancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.