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
Nice write-up. Any reason this has to be cmd? Will ps1 not work?
LikeLiked by 1 person
Hi James! Thank you for your comment. Yes, it is possible to copy the files using powershell. Ill leave this link for your reference: https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.management/copy-item?view=powershell-7.1
LikeLiked by 2 people
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.
LikeLike
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
LikeLike
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
LikeLike
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!
LikeLiked by 2 people
Thank you for your kind comments! I’m glad it was helpful for you!! 🙂
LikeLiked by 1 person
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?
LikeLike
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!
LikeLiked by 1 person
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?
LikeLike
Not working for me. Getting error code: 0x0 unknow in Intune portal. Here is my bat.cmd file
copy /Y .\Test.txt %systemRoot%\
LikeLike
Xcopy! Not copy.
LikeLike
I used this command:
xcopy /y .\file.txt “c:\temp” and this works great…maybe the missing ” ” in your command?
LikeLike
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.
LikeLike
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🤣)
LikeLike
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.
LikeLike
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
LikeLike
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”
LikeLike
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
LikeLike
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
LikeLike
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.
LikeLike
I ve tested only copy files. But Maybe:
xcopy /Y .\yourFolderInIntunewinpack “c:\yourPath”
Important!!! Dont forget the ” ” in your Pathname
LikeLike
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.
LikeLiked by 1 person
Hey. Did you have any scrip to unzip and the end user?
LikeLike
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
LikeLike
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?
LikeLike
Hi, in file explorer I can access the path without any issue. Yes I run the command as admin. Thanks
LikeLike
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.
LikeLiked by 1 person
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.
LikeLiked by 1 person
Thank you for your comment AK! 🙂
LikeLike
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
LikeLike
Hi VNM, thank you for your comment. My first recommendation is test the cmd only to see how it behaves and if the files are copied without any issues, then proceed with the creation of the intune package. Also you can follow this guide to troubleshoot the installation:
https://docs.microsoft.com/en-us/mem/intune/apps/apps-win32-troubleshoot
Hope it gets resolved,
Gianelli G
LikeLike
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
LikeLiked by 1 person
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?
LikeLiked by 1 person
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! 🙂
LikeLike
Thank for that,
Is there a way to copy the full directory (Main folder and subfolders/files) ?
LikeLike
Thank you for the article, and for everyone who added their comments. Took as a base and made my task done.
LikeLike