How to Create Registry Keys Using Intune Win32 App

In this blog post, we’ll use the Win32 app deployment method to deploy the registry key and its entries within the HKLM registry node. Also, you can 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 Remediations method.

If you need to back up and remove a registry key, 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

Numerous use cases exist 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 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 export the registry key, right-click on it and then choose the Export option.
  • Please provide the file’s name and Save it. It will be saved with the file extension .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 the name of our Powershell script.

CloudInfraregImport.ps1

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 else.
.\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

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

  1. Sign in to the 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 the App package file for the Win32 App

Provide Name, Description and Publisher Information

  • Name: CloudInfraReg Import
  • Description: Keep the default, or to change it, 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 long your application would take to complete the Installation. If it takes longer than the specified time, the Installation will fail. The default time is 60 minutes; 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 to deploy the app. If your devices mix 32-bit and 64-bit types, check the boxes for 32-bit and 64-bit in the Operating system architecture drop-down. Else, 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 Add groups and select the Entra security group containing Windows 10/11 test devices. Once testing proves successful, you can expand the deployment by including additional devices in the group.

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 from the device itself or remotely through the Intune admin center.

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

STEP 4 – Monitoring the Deployment Progress

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

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

From the application’s Overview page, you can check the status of Installation and Failures. To find more details on which devices the app is pushed successfully, click on Device Install 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 the Run dialog box.
  • Type regedit and press enter.
  • Navigate to HKEY_LOCAL_MACHINE\SOFTWARE\ to find the registry key ATestKey-Cloudinfra.net and 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 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. 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 and remediations > Platform scripts on the Intune admin center for more information. Refer to this step-by-step guide: How to deploy Powershell script using Intune for more details.

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

Leave a Comment