Q:

How to copy one file to a specific subdirectory in all application data directories in C:\Users?

One Windows 7 x64 I am trying to copy one file to
C:\users\profilename\AppData\Roaming\Autodesk\AutoCAD 2011\R18.1\enu\Plotters

I would like the batch to copy this file to all user profiles that exist on the client PC silently with no prompts.
The code I have tried so far with no luck:
@echo off
xcopy /I /Y "%~dp0myfile.pc3" "C:\Users\*\Appdata\Roaming\Autodesk\AutoCAD 2011\R18.1\enu\Plotters"

Any ideas on how to do this with a batch file?

A:

Wildcards can't be used inside a folder path. The Windows command interpreter does support that.
You could use the following code:
@echo off
setlocal EnableExtensions
set "TargetPath=AppData\Roaming\Autodesk\AutoCAD 2011\R18.1\enu\Plotters"

rem Get path of folder containing the users' profile folders.
for /F %%I in ("%PUBLIC%") do set "UsersFolder=%%~dpI"

rem Copy file into a subdirectory of each non standard user profile folder.
for /D %%I in (%UsersFolder%*) do (
    if /I not "%%I" == "%PUBLIC%" (
        if /I not "%%~nxI" == "Default" (
            if not exist "%%I\%TargetPath%\*" md "%%I\%TargetPath%"
            copy /B /Y "%~dp0myfile.pc3" "%%I\%TargetPath%\" >nul
        )
    )
)
endlocal

The subfolders Default and Public are skipped by this batch code.
This batch file must be of course run as administrator as otherwise the file can be only copied to %APPDATA%\Autodesk\AutoCAD 2011\R18.1\enu\Plotters, i.e. the appropriate subdirectory in the application data directory of AutoCAD 2011 of the current user account.
For understanding the used commands and how they work, open a command prompt window, execute there the following commands, and read entirely all help pages displayed for each command very carefully.

copy /?
echo /?
endlocal /?
for /?
if /?
md /?
rem /?
set /?
setlocal /?

