How to Create Registry Keys Using Intune Win32 App

In this blog post, we’ll use the Win32 app deployment method to deploy registry key and its entries within the HKLM registry node. Additionally, you can use the Win32 app deployment method to deploy registry keys and entries under the HKCU node by deploying the application within the User Context.

HKCU is a short form of HKEY_CURRENT_USER. It contains the configuration information for the user who is currently logged on. The user’s folders, screen colors and Control Panel settings are stored here. This information is associated with the user’s profile. To deploy registry keys and entries using Intune Device remediations, refer to this step-by-step guide: How to create HKCU registry keys using Intune remediations

HKLM” is an abbreviation for “HKEY_LOCAL_MACHINE“, which stores information related to the operating system and application configuration settings. In this blog post, I’ve utilized the Win32 app deployment method to deploy HKLM registry keys and entries. You can achieve identical outcomes by using the Intune device remediations method as well.

If you need to back up and remove a registry key, you can refer to my other blog post, which offers guidance on addressing the CVE-2022-30190 vulnerability. It also outlines the steps for backing up and deleting a registry key using Intune. It utilizes the Powershell script deployment method.

How to create a registry Key and values using Powershell

Step-by-step guide

There are numerous use cases for deploying registry keys on Windows devices using Intune. While I can’t cover every scenario here, I can highlight a few examples:

  1. Post-deployment application configuration: After installing software, you can use registry keys to configure and customize the application settings to suit your specific needs.
  2. License configuration or activation: Registry keys can be used to manage software licenses and activation for various installed applications.
  3. Operating system configuration settings: You can deploy registry keys to adjust and fine-tune operating system settings to align with your requirements.
  4. Enabling or disabling application features: Registry keys can enable or disable specific features within applications, allowing you to tailor the software’s functionality to your preferences.

STEP 1 – Export Registry Key

  1. On any Windows 10/11 device, Open Registry Editor.
  2. Create the registry keys that match your desired configuration on the target devices

Example:

  • For demonstration purposes, I’ve created a registry key named “ATestKey-Cloudinfra.net” within the HKEY_LOCAL_MACHINE\SOFTWARE path and added a few DWORD and String-type registry entries to it.
  • To export the registry key, right-click on it and then choose the “Export” option.
  • Provide a Name of the file and Save it. It will be saved with a file extension of .reg.
Export Registry Key in .reg file
Export Registry Key in .reg file
  • The screenshot below shows the .reg file we exported.
Registry key file contents
Registry key file contents

STEP 2 – Create an IntuneWin file

The next step is to create an Intunewin file. Follow the below steps:

  • Create a PowerShell script using the provided code, and replace the “.reg” file name with your exported .reg file name. For Example: CloudInfraregImport.ps1 is our Powershell script name.
reg import .\AtestkeyCloudInfra.reg
  • You can create an empty folder anywhere on your device and place the registry export file (.reg file) and the PowerShell script file into that folder.
Copy all the files in one folder
Copy all the files in one folder
  • Create an empty folder for example C:\output or anywhere you like.
.\IntuneWinAppUtil.exe -c "D:\RegImportv6" -s CloudInfraRegImport.ps1 -o C:\output
Create IntuneWin file
Create IntuneWin file
  • Now, check “C:\output” folder to confirm whether .Intunewin file has been successfully created.
Intunewin file created
Intunewin file created

STEP 3 – Create Win32 App Deployment on Intune admin center

Please follow the steps below to create an Intune Windows app (Win32) using the .Intunewin file.

  1. Login on Microsoft Intune admin center
  2. Click on Apps and then click on All Apps
  3. Click on + Add and Select Windows app (Win32) from the app type

App Information Tab

  • Browse to .Intunewin file we created in previous steps.
Browse to App package file for Win32 App
Browse to App package file for Win32 App

Provide Name, Description and Publisher Information

  • Name: CloudInfraReg Import
  • Description: Keep Default or to change click Edit Description.
  • Publisher: Cloudinfra.net
Provide Information about Win32 App
Provide Information about Win32 App

Program Tab

Provide the install command, uninstall command, install behavior, and device restart behavior. Then click “Next” to proceed.

  • Install command: %windir%\sysnative\WindowsPowerShell\v1.0\powershell.exe -Executionpolicy Bypass .\CloudInfraregImport.ps1
  • Uninstall command: %windir%\sysnative\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy Bypass -Command “Remove-Item -Path ‘HKLM:\SOFTWARE\ATestKey-Cloudinfra.net’ -Force”
  • Installation time required (mins): Specify how much time your application would take to complete the Installation. If it will take longer than the specified time, the Installation will fail. The default is 60 minutes and the Maximum time you can specify is 1 day (1440 minutes).
  • Install behavior: System
  • Device restart behavior: No specific Action
Provide Install and Uninstall Commands which will execute on target devices
Provide Install and Uninstall Commands which will execute on target devices

Requirements Tab

You can specify the requirements that devices must meet in order to deploy the app. If your devices are a mix of 32-bit and 64-bit types, then check both the boxes for 32-bit and 64-bit in the Operating system architecture drop-down. Else, just go with 64-bit.

  • Operating System Architecture: 64-bit
  • Minimum operating system: Select the minimum OS requirement for this deployment.

Detection Rules

Select Manually configure detection rules and click on +Add to add a detection rule.

  • Rules Format: Select Manually configure detection rules
  • Rule Type: Registry
  • Key path: HKEY_LOCAL_MACHINE\SOFTWARE\ATestKey-Cloudinfra.net
  • Detection method: Key exists
  • Associated with 32-bit app on 64-bit clients: No
Configure Detection rule for Win32 App
Configure Detection rule for Win32 App

Assignments Tab

Click on Add group to add an Azure AD group containing users or devices. You can also click on Add all users or Add all devices.

Review + Create

Review the deployment and click on Create to start the deployment process.

Sync Intune Policies

The device check-in process might not begin immediately. If you’re testing this policy on a test device, you can manually kickstart Intune sync either from the device itself or remotely through the Intune admin center.

Alternatively, you can use PowerShell to force the Intune sync on Windows devices. Another way to trigger the Intune device check-in process is by restarting the device.

STEP 4 – Monitoring the Deployment Progress

To check the Installation status of the app, You can follow below steps:

  • From Intune admin center, Click on Apps on the left hand side.
  • Click on All apps.
  • Search for the app CloudInfraReg Import and click on it.

From the Overview page of the application, you can check the status of Installation and Failures. To find more details on which devices the app is pushed successfully, you can also click on Device Install status or User Install status.

Monitoring Registry Deployment from Intune from Intune admin center
Monitoring Registry Deployment from Intune from Intune admin center

End-user Experience

To confirm the successful import of the registry key and its entries, please restart the target device and wait a few minutes for the PowerShell script to download and execute. You can then verify it by following these steps:

  • Press Win Key + R to open Run dialog box.
  • Type regedit and press enter.
  • Navigate to HKEY_LOCAL_MACHINE\SOFTWARE\ to find the registry key ATestKey-Cloudinfra.net along with registry entries created.
Verification of registry key and registry entries creation on target device
Verification of registry key and registry entries creation on target device

Conclusion

In this blog post, we’ve learned how to create registry keys using the Intune Win32 App method. We deployed a registry key under the HKLM (HKEY_LOCAL_MACHINE) registry node. It’s worth noting that you can also use the Win32 App method to deploy registry keys under the HKCU (HKEY_CURRENT_USER) registry node.

You can also deploy a simple Powershell script to Deploy registry keys. Go to Devices > Scripts on Intune admin center to find more information. You can also refer to my step-by-step guide: How to deploy Powershell script using Intune

1 thought on “How to Create Registry Keys Using Intune Win32 App”

Leave a Comment