ANAVEM
Languagefr
How to Deploy Batch Files to Windows Devices using Microsoft Intune

How to Deploy Batch Files to Windows Devices using Microsoft Intune

Convert batch files to .intunewin format and deploy them as Win32 applications through Microsoft Intune to managed Windows devices with proper detection rules.

March 29, 2026 15 min
mediumintune 8 steps 15 min

Why Deploy Batch Files Through Microsoft Intune?

Managing Windows devices at scale requires efficient deployment mechanisms for configuration scripts, software installations, and system modifications. While PowerShell scripts offer advanced capabilities, batch files remain essential for legacy system integration, simple automation tasks, and environments where PowerShell execution policies restrict script deployment.

Microsoft Intune's Win32 application deployment framework provides a robust solution for distributing batch files to managed Windows devices. Unlike traditional Group Policy or manual deployment methods, Intune offers cloud-based management, detailed reporting, and flexible targeting options that work seamlessly with modern device management scenarios.

What Makes Intune Batch Deployment Different?

The key advantage of deploying batch files through Intune lies in the Win32 Content Prep Tool's ability to package your scripts into .intunewin format. This packaging process encapsulates your batch file with metadata, dependencies, and execution parameters, creating a deployable application that Intune can manage like any other software package.

This approach provides several benefits over traditional deployment methods: centralized management through the Microsoft Endpoint Manager admin center, detailed execution logging and status reporting, flexible scheduling and targeting options, and automatic retry mechanisms for failed deployments. The system-level execution context ensures your batch scripts run with appropriate privileges, while detection rules provide reliable verification of successful deployment.

What Will You Accomplish?

By following this tutorial, you'll master the complete workflow for converting batch files into Intune-deployable applications. You'll learn to create robust batch scripts with proper logging and error handling, package them using Microsoft's official tools, configure deployment parameters and detection rules, and monitor rollout success across your Windows device fleet. This knowledge enables you to automate configuration tasks, deploy legacy applications, and maintain consistent system states across your managed environment.

Implementation Guide

Full Procedure

01

Download and Set Up the Win32 Content Prep Tool

First, download the Microsoft Win32 Content Prep Tool from the official GitHub repository. This tool converts your batch file into the .intunewin format required for Intune deployment.

Navigate to https://github.com/Microsoft/Microsoft-Win32-Content-Prep-Tool and download the latest IntuneWinAppUtil.exe file.

Create a working directory structure on your packaging workstation:

mkdir C:\IntunePackaging
mkdir C:\IntunePackaging\Source
mkdir C:\IntunePackaging\Output

Copy the downloaded IntuneWinAppUtil.exe to C:\IntunePackaging.

Pro tip: Always use the latest version of the Win32 Content Prep Tool to ensure compatibility with current Intune features and avoid packaging issues.

Verification: Run the following command to confirm the tool works:

cd C:\IntunePackaging
IntuneWinAppUtil.exe

You should see the tool's help information displaying available parameters.

02

Create Your Batch File with Proper Logging

Create a robust batch file that includes logging and error handling. This ensures you can troubleshoot deployment issues and verify successful execution.

Create a new file called deploy.bat in C:\IntunePackaging\Source:

@echo off
setlocal enabledelayedexpansion

REM Set up logging
set LOGFILE=C:\Windows\Temp\batch_deployment.log
set COMPLETION_FILE=C:\Windows\Temp\batch_deployment_complete.txt

REM Start logging
echo ============================================ >> %LOGFILE%
echo Starting batch deployment script >> %LOGFILE%
echo Timestamp: %date% %time% >> %LOGFILE%
echo Running as: %USERNAME% >> %LOGFILE%
echo ============================================ >> %LOGFILE%

REM Example: Create a company directory
mkdir "C:\CompanyApps" >> %LOGFILE% 2>&1
if %ERRORLEVEL% NEQ 0 (
    echo ERROR: Failed to create directory >> %LOGFILE%
    exit /b 1
)

REM Example: Copy configuration files
echo Copying configuration files... >> %LOGFILE%
REM xcopy "config\*" "C:\CompanyApps\" /Y >> %LOGFILE% 2>&1

REM Example: Install MSI silently (uncomment and modify as needed)
REM echo Installing application... >> %LOGFILE%
REM msiexec /i "setup.msi" /quiet /norestart /l*v C:\Windows\Temp\msi_install.log
REM if %ERRORLEVEL% NEQ 0 (
REM     echo ERROR: MSI installation failed with code %ERRORLEVEL% >> %LOGFILE%
REM     exit /b %ERRORLEVEL%
REM )

REM Create completion marker
echo Deployment completed successfully > "%COMPLETION_FILE%"
echo Batch deployment completed successfully >> %LOGFILE%
echo End timestamp: %date% %time% >> %LOGFILE%

exit /b 0
Warning: Avoid using spaces in file and folder names within your batch script and source directory. Spaces can cause the Win32 Content Prep Tool to fail during packaging.

Verification: Test your batch file locally by running it from an elevated command prompt:

cd C:\IntunePackaging\Source
deploy.bat

Check that the log file and completion marker are created in C:\Windows\Temp.

03

Package the Batch File with Win32 Content Prep Tool

Now convert your batch file into the .intunewin format that Intune can deploy. The Win32 Content Prep Tool will create a package containing your batch file and any dependencies.

Open an elevated command prompt and navigate to your packaging directory:

cd C:\IntunePackaging

Run the Win32 Content Prep Tool with the following parameters:

IntuneWinAppUtil.exe -c "C:\IntunePackaging\Source" -s "deploy.bat" -o "C:\IntunePackaging\Output"

When prompted for the catalog folder, type N and press Enter (unless you have specific catalog requirements).

The tool will process your files and create a deploy.intunewin file in the output directory.

Pro tip: If you have additional files (MSI installers, configuration files, etc.) that your batch script needs, place them all in the Source folder before packaging. The tool will include everything in the source directory.

Verification: Confirm the .intunewin file was created successfully:

dir C:\IntunePackaging\Output\*.intunewin

You should see deploy.intunewin with a file size greater than 0 bytes.

04

Upload the Package to Microsoft Intune

Access the Microsoft Endpoint Manager admin center and upload your packaged batch file as a new Win32 application.

Open your web browser and navigate to https://endpoint.microsoft.com. Sign in with your Intune administrator credentials.

Navigate through the portal:

  1. Click Apps in the left navigation pane
  2. Select All apps
  3. Click Add
  4. Choose Windows app (Win32) from the app type dropdown
  5. Click Select

In the App package file section:

  1. Click Select app package file
  2. Browse to C:\IntunePackaging\Output
  3. Select deploy.intunewin
  4. Click OK

Wait for the file to upload and process. Intune will extract metadata from your package.

Verification: After upload, you should see the app information populated with details like:

  • Name: deploy
  • Publisher: (your organization)
  • Command line: deploy.bat

Click Next to proceed to app configuration.

05

Configure App Information and Program Settings

Configure the application details and program execution settings to ensure proper deployment behavior on target devices.

In the App information section, fill in the required fields:

  • Name: Company Batch Deployment Script
  • Description: Automated deployment script for company configuration
  • Publisher: Your Organization Name
  • Category: Business (or appropriate category)
  • Optionally upload a logo image

Click Next to proceed to Program settings.

In the Program section, configure the execution parameters:

SettingValueDescription
Install commanddeploy.batThe batch file to execute
Uninstall command(leave blank)Not applicable for batch scripts
Install behaviorSystemRuns with SYSTEM privileges
Device restart behaviorDetermine behavior based on return codesHandles restart requirements automatically

Configure return codes by clicking Add and setting:

  • Return code: 0, Code type: Success
  • Return code: 1641, Code type: Soft reboot
  • Return code: 3010, Code type: Soft reboot
  • Return code: 1618, Code type: Retry
Warning: Always include explicit return codes in your batch script using exit /b 0 for success. Intune interprets missing or incorrect return codes as failures, causing unnecessary retry attempts.

Verification: Review your program settings to ensure the install command shows deploy.bat and install behavior is set to System.

06

Set Requirements and Detection Rules

Define the system requirements and detection logic that Intune will use to determine deployment eligibility and success.

In the Requirements section, configure:

  • Operating system architecture: 64-bit (recommended)
  • Minimum operating system: Windows 10 21H1 or later
  • Add any additional requirements like disk space or memory if needed

Click Next to proceed to Detection rules.

In the Detection rules section, click Add and configure a file-based detection rule:

SettingValue
Rules formatManually configure detection rules
Rule typeFile
PathC:\Windows\Temp
File or folderbatch_deployment_complete.txt
Detection methodFile or folder exists
Associated with a 32-bit appNo

This detection rule tells Intune to check for the completion marker file that your batch script creates upon successful execution.

Pro tip: Use file-based detection rules rather than registry entries for batch scripts. Files are more reliable and easier to troubleshoot than registry modifications.

Verification: Confirm your detection rule shows the correct path and filename. The rule should appear as: File - C:\Windows\Temp\batch_deployment_complete.txt exists.

07

Assign the Application to Target Groups

Configure deployment assignments to specify which users or devices should receive the batch file deployment.

Click Next to skip Dependencies (unless your batch script requires other applications to be installed first).

In the Assignments section, click Add group under the appropriate assignment type:

  • Required: Automatically installs on assigned devices
  • Available for enrolled devices: Users can install from Company Portal
  • Uninstall: Removes the application (not applicable for batch scripts)

For a typical deployment, choose Required and configure:

  1. Click Select groups
  2. Choose your target device group (e.g., "All Windows Devices" or "Test Devices")
  3. Set Make this app required for all devices to Yes
  4. Configure delivery optimization if needed

Set the assignment schedule:

  • Assignment type: Required
  • Start date and time: As soon as possible (or schedule for later)
  • Deadline: As soon as possible

Click Next to proceed to Review + create.

Verification: Review the assignment summary to ensure your target group is listed under Required assignments with the correct schedule.

08

Deploy and Monitor the Application

Complete the deployment process and monitor the rollout to ensure successful execution across your target devices.

In the Review + create section, verify all your configuration settings:

  • App information matches your requirements
  • Install command is deploy.bat
  • Detection rule points to the completion marker file
  • Target groups are correctly assigned

Click Create to deploy the application.

Monitor the deployment progress:

  1. Navigate to Apps > All apps
  2. Find your "Company Batch Deployment Script" application
  3. Click on it to view details
  4. Select Device install status to see per-device results

Check deployment status on target devices using PowerShell:

# Check if completion marker exists
Test-Path "C:\Windows\Temp\batch_deployment_complete.txt"

# View deployment log
Get-Content "C:\Windows\Temp\batch_deployment.log" -Tail 20

# Check Intune management extension logs
Get-WinEvent -LogName "Microsoft-Windows-DeviceManagement-Enterprise-Diagnostics-Provider/Admin" | Where-Object {$_.TimeCreated -gt (Get-Date).AddHours(-2)} | Select-Object TimeCreated, LevelDisplayName, Message
Pro tip: If deployment fails, check the Intune Management Extension logs on the target device at C:\ProgramData\Microsoft\IntuneManagementExtension\Logs for detailed error information.

Verification: Successful deployment should show:

  • Device install status: Installed
  • Completion marker file exists on target devices
  • Log file shows successful execution without errors

Frequently Asked Questions

Can I deploy batch files directly to Intune without converting to .intunewin format?+
No, Microsoft Intune requires all Win32 applications, including batch files, to be packaged in .intunewin format using the Win32 Content Prep Tool. This packaging process encapsulates your batch file with metadata and dependencies, enabling Intune to manage deployment, detection, and reporting. Direct batch file upload is not supported in the current Intune architecture.
What happens if my batch file fails to execute on target devices?+
Intune will retry failed deployments based on your configured return codes and retry settings. Check the Intune Management Extension logs on affected devices for detailed error information. Common failure causes include incorrect file paths, missing dependencies, or permission issues. Ensure your batch script includes proper error handling and logging to facilitate troubleshooting.
How do I update an already deployed batch file in Intune?+
To update a deployed batch file, modify your source script, repackage it using the Win32 Content Prep Tool to create a new .intunewin file, then upload the updated package to your existing Intune application. Intune will detect the version change and redeploy to assigned devices. Consider incrementing version numbers in your script for better tracking.
Can batch files deployed through Intune access network resources and mapped drives?+
Batch files deployed via Intune run in the SYSTEM context, which may not have access to user-mapped network drives or resources requiring user authentication. For network access, use UNC paths with embedded credentials or configure your batch script to run in user context. Consider using PowerShell scripts for more advanced network operations and credential management.
What are the size limitations for batch files and dependencies in Intune deployment?+
The maximum size for a Win32 app package (.intunewin file) in Microsoft Intune is 8 GB. This includes your batch file and all dependencies packaged together. For large deployments, consider splitting into multiple applications or using cloud storage with download scripts. Most batch file deployments are well under this limit, but be mindful when including large MSI installers or data files.

Discussion

Share your thoughts and insights

Sign in to join the discussion