Deploy Batch File using Intune Step by Step Guide

Let’s learn how to deploy a batch file from Intune in this guide. We will explore using batch file deployment options through the Intune portal. The Application deployed using the batch file gets automatically installed on Intune managed devices.

A batch file is a script that contains a series of commands that can be executed by the Windows command prompt (cmd.exe). Deploying a batch file using Intune allows you to automate various tasks on devices managed by Intune.

Win32 applications from Intune are a highly utilized feature, offering numerous benefits and enabling various use cases. Leveraging batch or command file deployment directly can streamline the automatic process of customizations and perform any specific actions.

Intune offers a diverse range of supported application types, catering to various platforms and requirements. It includes the applications such as Store apps, Microsoft apps, Android enterprise system apps, LOB apps, macOS apps, Windows apps, check more about the List Of Supported Intune Application Types.

Patch My PC

Before adding a Win32 app to Microsoft Intune, you must prepare the app using the Microsoft Win32 Content Prep Tool. You use the Win32 Content Prep Tool to pre-process Windows classic (Win32) apps, Intune Win32 App Deployment Step By Step Guide. 

Prepare Batch File to Perform Task

Create your batch file with the necessary commands to be executed on the targeted devices. Test the batch file thoroughly to ensure it works as expected. Once you have done this, You just need to keep your script file in the folder.

Here is the sample batch script to clean up the Temp folder in Windows. The Temp folder typically contains temporary files that are no longer needed and can be safely deleted. You can also add the batch file (.cmd or .bat) that can be used later during the application creation process using Intune.

@echo off
set "tempFolder=%TEMP%"
echo Cleaning up the Temp folder: %tempFolder%

rem List all files in the Temp folder (excluding subfolders)
for %%F in ("%tempFolder%\*") do (
    if not "%%~xF"=="" (
        echo Deleting file: "%%F"
        del "%%F" /q

echo Temp folder cleanup completed.

The next step is to convert your files to .intunewin for uploading in Intune and start app creation using Win32 App. Download the updated IntuneWinAppUtil.exe from GitHubRun IntuneWinAppUtil.exe file, Run as administrator.

  • Please specify the source folder – Enter the folder that contains your application setup files. (For Example, C:\Source)
  • Please specify the setup file – Enter the setup file name (such as setup.exe, setup.msi, or setup.cmd). For Example, CleanupTemporaryFiles.bat
  • Specify the output folder – Input the output folder to generate the .intunewin file. (For Example, Output)
  • Do you want to specify catalog folder – Type N.
Deploy Batch File using Intune Fig.1
Deploy Batch File using Intune Fig.1

After the process is finished, navigate to the output folder to collect the Intune Win32 app deployment file.

NOTE! If the content size is less, the Win32 Content Prep Tool runs and quickly closes the command prompt windows. When the process is complete and the .intunewin file is generated, the status will show 100% at the bottom of the command prompt.

Deploy Batch File from Intune

Let’s follow the steps to deploy batch file from Intune, The first step is to upload the Intunewin file for deploying Windows batch files to managed devices. Here’s how you can deploy batch file using Intune.

  • Sign in to the Microsoft Intune admin center
  • Select Apps > All apps > Add, or you can navigate to Apps > Windows > Windows Apps.
  • On the Select app type pane, select Windows app (Win32) under the Other app types and click Select.
Deploy Batch File using Intune Fig.2
Deploy Batch File using Intune Fig.2

On the Add app pane, click Select app package file. Select the browse button. Then, select the prepared file with the extension .intunewin. The app details appear. When you’re finished, select OK on the App package file pane.

Deploy Batch File using Intune Fig.3
Deploy Batch File using Intune Fig.3

Enter the Name of the Windows App Win32 (For Example, Cleanup Temporary Files – Windows), and Enter the Description of the Windows App.

Enter the Publisher name, and You may specify the additional app information here. Upload an icon for the app. This icon is displayed with the app when users browse the company portal and Click Next.

Deploy Batch File using Intune Fig.4
Deploy Batch File using Intune Fig.4

The most important part is to specify the commands. On the Program, configure the app installation and removal commands for the app:

  • Install command: Add the complete installation command line to silent install. For Example, CleanupTemporaryFiles.bat
  • Uninstall command: Add the uninstallation command line. For Example, CleanupTemporaryFiles.bat
  • Install behavior: Set the install behavior to System or User.

You can also specify the Device restart behavior and Post-installation behavior. Click Next to continue.

Deploy Batch File using Intune Fig.5
Deploy Batch File using Intune Fig.5

On the Requirements page, specify the mandatory requirements that devices must meet before installing the update and click Next.

  • Operating system architecture: Choose the architectures needed to install.
  • Minimum operating system: Select the minimum operating system needed to install.

There are some built-in and custom requirements rules when creating your Win32 application. Explore Intune Win32 App Requirement Rules.

Deploy Batch File using Intune Fig.6
Deploy Batch File using Intune Fig.6

On the Detection rules pane, configure the rules to detect the presence of the app. You can choose to add multiple rules.

Here I selected the Manually configure detection rules format. Click on Add button, and A popup will appear showing the Detection rule. This detection rule format provides three detection rules MSIFile, and Registry.

Here you can check the registry path for the applications. Most apps are installed in the same location depending on the app architecture – Detection Method for Intune Win32 App.

Deploy Batch File using Intune Fig.7
Deploy Batch File using Intune Fig.7

You can also specify app dependencies where the applications must be installed before your Win32 app can be installed.

In the scope tag section, you shall get an option to Configure scope tags for this Windows App Win32 application type.

Under Assignments, In Included groups, click Add groups and then choose Select groups to include one or more groups to which you want to deploy the batch file. Click Next to continue.

Deploy Batch File using Intune Fig.8
Deploy Batch File using Intune Fig.8

You will see the details you provided during the application creation process. Review your settings and select Create to add the app to Intune.

Deploy Batch File using Intune Fig.9
Deploy Batch File using Intune Fig.9

Upon proceeding with the creation, you will notice the status “Uploading in progress.” If you are wondering about the time it takes to complete the upload, it depends on both the size of the application and the speed of internet connectivity.

Deploy Batch File using Intune Fig.10
Deploy Batch File using Intune Fig.10

Please wait some time to complete the upload process, and you can check the progress by clicking on the Notification icon. Once the Intune package is uploaded and finished, you will get the status “Upload finished.”

Your groups will receive targeted deployment of batch file using Intune when the devices check in with the Intune service the policy applies to the device.

On the client machine, In the Company Portal, You can click on the apps to track the details and check the progress. Microsoft Intune company portal provides many branding options for Applications to provide a better user experience. Here you can check how Intune App deployed to the machine to display featured apps.

Monitor Deployment – Deploy Batch File from Intune

To monitor the installation status from Intune Portal, select the application, and here you can check the device and user check-in status. If you click on the Device install status for this application, additional details are displayed.

Deploy Batch File using Intune Fig.11
Deploy Batch File using Intune Fig.11

Track Batch File Installation Status

Let’s check the Application Deployment status from the logs in the client machine. To confirm the batch file has been installed successfully, you can also check it in Event Viewer or Registry.

You can track the details logged at IntuneManagementExtension.log located C:\ProgramData\Microsoft\IntuneManagementExtension\Log. You track the application activity in client devices. You can check Intune Win32 App Issues Troubleshooting for more details.

Once the application installation starts, the “Detection rule” will be evaluated. Checks were performed against the rules configured, and the app “Install command” will be triggered. You will get noticed the deployment of batch file using Intune.

Troubleshooting Win32 App References

Let’s learn Intune Win32 App Troubleshooting Client-Side Process Flow. You can look at the Level 3 deep dive troubleshooting Intune Management Extension (IME) Level 3 Troubleshooting Guide.

For troubleshooting Intune client-side events, you can refer to three logs in case you experience any issues while deploying the batch file using Intune.

  • IntuneManagementExtension.log: Tracks the Intune Management extension component events.
  • AgentExecuter: Track any PowerShell execution events.
  • ClientHealth.log:  Track client-health related events.


Leave a Comment

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