Copy files to Windows 10 devices using Microsoft Endpoint Manager

Hello Readers! I was working with a client last week who was looking to place some folders and files on a specific location (C drive) on their managed devices. The way we achieved it was, deploying a Win 32 package with the neccesary docs and a cmd file. Please keep reading and find out our results!♥

Below the steps:

Prepare your files to copy

Prepare a folder and add all the necessary files that you want to copy to managed devices.

Create a cmd file

Next, create a cmd file with the instructions to copy all the files previosuly added and place it on the same folder.

For our deployment we used the files as shown below:

The copyFiles.cmd file contains the following lines:

copy /Y .\Windows_EnrollmentTypesIntune.pptx %systemRoot%\
copy /Y .\Windows_AzureADRegistration.pdf %systemRoot%\
copy /Y .\IOS-iPadOS_EnrollmentTypes_.jpg %systemRoot%\

Run the Intune Utility to prepare the intunwin package

Download the Microsoft Intune Win32 App Upload Prep Tool and extract it to C:\Temp\ IntuneAppTool. You can download it here.

Create the output folder for the .intunewin package. For this example, we used the folder: C:\Users\gianelliadmin\Documents\ImportantFiles

Run powershell as admin and move to the directory where IntuneWinAppUtil was extracted to. For this example, the utility was located in C:\Temp\Microsoft-Win32-Content-Prep-Tool-master\

Run the utility using the directories accordingly.

.\IntuneWinAppUtil.exe
Please specify the source folder: C:\Users\gianelliadmin\Documents\ImportantFiles
Please specify the setup file: copyFiles.cmd
Please specify the output folder: C:\Users\gianelliadmin\Documents\ImportantFiles
Do you want to specify catalog folder (Y/N)?N

Create a Windows (Win32) app in Endpoint Manager

Upload the intune.win package and use the commands below:

1.Select the intunewin package and add the app information

2. Specify the install and uninstall command. This should be the name of the cmd file.

3. Specify the requirements

4. Add the detection rules. The path to place the files, File or Folder to add the name of at least one file and the Detection method select file or folder exists.

5. Scope the managed devices

Sync the managed device from the Endpoint Manager console and wait for the files to populate on the location.

Follow the steps above to test it on your end and don’t forget to post your questions, comments and results! ♥

Tip

If you want to copy a folder not only single files, use the xcopy command on your cmd file. Example: Xcopy C:\source C:\temp /E /H /C /I

37 thoughts on “Copy files to Windows 10 devices using Microsoft Endpoint Manager

      • oryx360 21 September, 2022 / 9:33 pm

        I need to copy files from the network share? When you package this through Intune, does it also package the files within it or how does it do? If it gets packaged during intune package process then it is fine, but if not how does it work for those machines that are just AAD joined? I am kind of confused here.

        I cannot keep these files to be residing on my computer but instead it has be on the network and from there it should copy out right? Please, could you help me in copying it from our network folder to OOBE devices.

        Like

      • oryx360 22 September, 2022 / 4:25 pm

        Hi Gianelli

        I tried to do the package of Intune and try to push it. Now, my question is should the wallpaper and the ps1 script be in the same folder or should it be outside the folder where the wallpapers reside?

        I used the following ps script

        New-Item -Path “C:\” -Name “Support\Backgrounds” -ItemType “directory” -force
        Copy Item -Path “Wallpaper\” -Destination “C:\Support\Backgrounds” -Recurse -force

        Wallpaper is a folder name

        Like

      • Gianelli G 5 October, 2022 / 1:24 pm

        Hello oryx360,

        Thank you for your message,
        It is better if it is outside the folder you are copying, remember that when you are packaging the file using the Intune tool you need to specify the path of your script. It is very helpful if you do a test using CMD or powershell in your case on your local machine before you package the folder to make sure, all is working as expected.

        Hope this helps,
        Gianelli G

        Like

  1. Matthias 2 April, 2021 / 8:39 am

    Thank you very much for this Skill! Thats so easy and works fine! This was the solution for my Problem!
    Very nice, i ve learned one Skill more!

    Liked by 2 people

    • Gianelli G 2 April, 2021 / 7:27 pm

      Thank you for your kind comments! I’m glad it was helpful for you!! 🙂

      Liked by 1 person

  2. MPinto 14 April, 2021 / 9:29 am

    I think this CMD solution does not work because Intune will “run as admin” an the origin path will begin at c:\windows\system32\ and you receive a message “Cannot find specified files”.
    Anyone else with this obstacle?

    Like

    • Matthias Thiedke 20 April, 2021 / 1:16 pm

      I use this Command to copy missing icons in a Application Folder.
      C:\Program Files (x86)\VMware\VMware Horizon View Client\rc
      This works great!

      Liked by 1 person

      • George 8 June, 2022 / 2:58 pm

        This is exactly what I am trying to use this script to do however mine isn’t working. Can you share a copy of the content you used within the .cmd file?

        Like

  3. Imtiaz 21 April, 2021 / 5:09 pm

    Not working for me. Getting error code: 0x0 unknow in Intune portal. Here is my bat.cmd file

    copy /Y .\Test.txt %systemRoot%\

    Like

    • Matthias 21 April, 2021 / 6:17 pm

      Xcopy! Not copy.

      Like

    • Matthias 21 April, 2021 / 6:36 pm

      I used this command:

      xcopy /y .\file.txt “c:\temp” and this works great…maybe the missing ” ” in your command?

      Like

      • Imtiaz 23 April, 2021 / 5:31 pm

        Xcopy works…thank you…
        However, I have noticed that Azure portal gives me two different errors on two different batch file. One error is App installation failed. Error Code: 0x0. The second app has failed error as well. But error code is
        Error code: 0x87D1041C
        The application was not detected after installation completed successfully
        Suggested remediation
        Couldn’t detect app because it was manually updated after installation or uninstalled by the user.

        In both cases, the required files are getting copied to the correct location. It’s just an eye sore to see failed messages in the portal. Plus, it will be hard to tell which one is genuine failure.

        Like

      • Matthias 23 April, 2021 / 7:13 pm

        I think the Problem is your Detection Rule. The Endpoint Manager cant check and verify the Rule. What is your Rule? Look for an File or Registry Entry?
        The Application would installed?

        (Sry for my English…my German is better🤣)

        Like

      • Imtiaz 27 April, 2021 / 7:44 pm

        Got it. Thank you for your help. My problem was due to detection rule. I saw your reply to Laxminarayana. The example of detection rule was very helpful.

        Like

  4. Laxmi 26 April, 2021 / 8:24 pm

    How do I copy entire folder with some 50 files inside it , I can copy one file but I want entire folder with many files within that , it throws error like 0x000004 unknown pls guide

    Like

    • Matthias 26 April, 2021 / 8:40 pm

      Look in Gianelli G Tutorial under “Tip” She says:

      …”If you want to copy a folder not only single files, use the xcopy command on your cmd file. Example: Xcopy C:\source C:\temp /E /H /C /I”

      Like

  5. Laxminarayana 27 April, 2021 / 3:22 am

    i have confusion with c:\source and c:\temp the detection rules what folder do we need to specify? the source is it where you have the files and what is destination as my XCOPY for folder and files failing with error 0x000004

    Like

    • Matthias 27 April, 2021 / 1:41 pm

      this is the content of my copyicons.cmd:

      Example:
      xcopy/Y .\filename “destination path”

      xcopy /Y .\server.png “c:\Program Files (x86)\VMware\VMware Horizon View Client\rc”
      xcopy /Y .\validated.jpg “c:\Program Files (x86)\VMware\VMware Horizon View Client\rc”
      xcopy /Y .\view_48x.png “c:\Program Files (x86)\VMware\VMware Horizon View Client\rc”

      Install command: copyicons.cmd
      uninstall command: copyicons.cmd

      Detection Rule:

      Type: File
      Path: C:\Program Files (x86)\VMware\VMware Horizon View Client\rc
      File or Folder: validated.jpg
      File or folder exists

      Like

  6. Laxmi 27 April, 2021 / 4:59 pm

    Thanks for your reply, the above is for copying individual files to the destination laptop, did you try copying entire folder was it successful.
    For example Xcopy C:\source C:\temp /E /H /C /I
    what is source here is it the location of the file were you have the folder on the machine and destination is where you want to move the file to the workstation?

    i tried this command but it didn’t work unfortunately.

    Like

  7. Matthias 29 April, 2021 / 6:44 am

    I ve tested only copy files. But Maybe:

    xcopy /Y .\yourFolderInIntunewinpack “c:\yourPath”

    Important!!! Dont forget the ” ” in your Pathname

    Like

  8. laxmi 4 May, 2021 / 7:48 am

    Hi,
    i was able to zip the folder into .zip format and followed the copy procedure and it works fine. Folder cannot be copied as per confirmation from microsoft it is by design it wont work.

    so zip the folder and make the copy.

    Liked by 1 person

    • Jouberth Ferraz 22 November, 2022 / 12:05 pm

      Hey. Did you have any scrip to unzip and the end user?

      Like

  9. asimashraf79 17 August, 2021 / 9:21 am

    Hi,
    I am getting “Access denied” error msg in Intune after I tried to save images on Microsoft Teams background folder. I use “%APPDATA%\Microsoft\Teams\Backgrounds\Uploads” but no success. I can copy the images to C:\temp and also to %systemroot%.
    Need help with this, thanks

    Like

    • Gianelli G 2 September, 2021 / 8:12 pm

      Hi! Thank you for your comment. When you access that path in the file explorer are you getting the same error? Are y ou running the cmd commands as admin?

      Like

      • asimashraf79 14 September, 2021 / 7:56 pm

        Hi, in file explorer I can access the path without any issue. Yes I run the command as admin. Thanks

        Like

    • Blessing 24 September, 2021 / 6:12 am

      You can try the following approach that makes us of a scheduled task:

      Script #1 – Copies the source files (thump.png) to a cache folder on the client device and creates a scheduled task that will run at user logon. This is the script that will be called by the Win32 app.

      IF NOT EXIST “C:\ProgramData\MDMManagedApps\BrandTemplates\Teams” MD “C:\ProgramData\MDMManagedApps\BrandTemplates\Teams”
      IF NOT EXIST “C:\ProgramData\MDMManagedApps\Scripts” MD “C:\ProgramData\MDMManagedApps\Scripts”

      copy /Y .\thumb.png “%programdata%\MDMManagedApps\Teams”
      copy /Y .\CallMSTeams.cmd “%programdata%\MDMManagedApps\Scripts\CallMSTeams.cmd”
      copy /Y .\CRSTeamsBackground.xml “%programdata%\MDMManagedApps\Scripts\TeamsBackground.xml”

      tasklist /FI “IMAGENAME eq TeamsBackground ” 2>NUL | find /I /N “TeamsBackground”>NUL
      if “%ERRORLEVEL%”==”1” Goto SCHEDULE
      GOTO EXIT

      :SCHEDULE
      SCHTASKS /create /XML “%programdata%\MDMManagedApps\Scripts\TeamsBackground.xml” /TN TeamsBackground
      del “%programdata%\MDMManagedApps\Scripts\TeamsBackground.xml”

      :EXIT
      EXIT

      Script #2 – Runs at user logon and copies the file thump.png to uploads folder if it does nor exist

      IF NOT EXIST “%userprofile%\AppData\Roaming\Microsoft\Teams\Backgrounds\Uploads” MD “%userprofile%\AppData\Roaming\Microsoft\Teams\Backgrounds\Uploads”

      IF NOT EXIST “%userprofile%\AppData\Roaming\Microsoft\Teams\Backgrounds\Uploads\thump.png” copy /Y “%programdata%\MDMManagedApps\CRSBrandTemplates\Teams\Thump.png” “%userprofile%\AppData\Roaming\Microsoft\Teams\Backgrounds\Uploads”

      Finally package the 2 batch files and Scheduled task XML file into an IntuneWin app and create a Win32 package.

      Liked by 1 person

  10. AK 24 March, 2022 / 7:47 pm

    Thank you very much. I used the steps in your article to push out a vpn profile to managed devices. I’m new to Intune MDM so this was very helpful.

    Liked by 1 person

  11. VNM 23 August, 2022 / 1:17 pm

    Hello,
    We tried your method but the deployment from Intune through the Company Portal is not installing on the device and is taking forever. We tried to switch between the system context and user context system behaviour but that didn’t help. Please let us know if we are missing out something.

    Thank you !

    BR,
    VNM

    Like

  12. Abrar Ali 7 September, 2022 / 4:34 pm

    Hi Gianelli,

    Excellent post and exactly what I was looking for. However, when I tried to implement this, only 1 file is getting copied, while I was trying to copy 3 files.

    Tested it twice, thinking I made some error and still the same behaviour. Below is my .cmd content.

    cmd /c mkdir “C:\Intune_Wallpapers\”
    copy /Y .\ML_Desktop.jpg “C:\Intune_Wallpapers\”
    copy /Y .\Sept_2022.jpg “C:\Intune_Wallpapers\”
    copy /Y .\Sept_2022.scr “C:\Intune_Wallpapers\”

    Anyhelp will be greatly appreciated.

    Thanks,
    Abrar Ali

    Liked by 1 person

  13. Abrar 12 September, 2022 / 12:14 pm

    Hi Gianelli,

    Thanks for providing a detailed writeup, this is exactly what I was looking for. However, when I try to create the win32 file, following the instructions, it is only copying the first file and the rest of the files are not getting copied.

    cmd /c mkdir “C:\Intune_Wallpapers\”
    copy /Y .\ML_Desktop.jpg “C:\Intune_Wallpapers\”
    copy /Y .\Sept_2022.jpg “C:\Intune_Wallpapers\”
    copy /Y .\Sept_2022.scr “C:\Intune_Wallpapers\”

    Can someone please help?

    Liked by 1 person

  14. Gianelli G 13 September, 2022 / 9:38 am

    Hi Abrar, thank you for your comment

    I did test it on my end and it seems that there is an issue with your quotes,

    try this

    cmd /c mkdir “C:\Intune_Wallpapers\”
    copy /Y .\ML_Desktop.jpg “C:\Intune_Wallpapers\”
    copy /Y .\Sept_2022.jpg “C:\Intune_Wallpapers\”
    copy /Y .\Sept_2022.scr “C:\Intune_Wallpapers\”

    or you can actually remove them since there isnt a space on your folder name

    cmd /c mkdir C:\Intune_Wallpapers\
    copy /Y .\ML_Desktop.jpg C:\Intune_Wallpapers\
    copy /Y .\Sept_2022.jpg C:\Intune_Wallpapers\
    copy /Y .\Sept_2022.scr C:\Intune_Wallpapers\

    My recommendation is that you first run the cmd locally, to validate it and then create the package with Intune tool.

    Hope this helps! 🙂

    Like

  15. Jouberth Ferraz 18 November, 2022 / 3:57 pm

    Thank for that,
    Is there a way to copy the full directory (Main folder and subfolders/files) ?

    Like

  16. alexnikulin78 6 April, 2023 / 7:02 pm

    Thank you for the article, and for everyone who added their comments. Took as a base and made my task done.

    Like

Leave a comment