I'm updating a file in every user profile. The location is fairly deep \profiles\\appdata\roaming\microsoft\imagelogo.jpg and I'm replacing it with a newer file of the same name. I would like to do this for all profiles. Is there a good way to replace all files based on filename?

link|improve this question
feedback

2 Answers

up vote 1 down vote accepted

A way of doing this in one swoop would be as follows:

cd path\to\user\profiles
for /d %i in (*) do copy /y newimagelogo.jpg %1\appdata\roaming\microsoft

Despite this, I'd use with Judaslscariot's answer for the following reason:

If a user is logged on when you run this, the image currently in that user's roaming profile will overwrite the image you've just copied, when they log off.

link|improve this answer
Thanks. I was looking to avoid using a login script. Your method worked. The profile sync will work as intended so long as the modified date is newer. – Ryan Jan 24 at 18:34
feedback

Create a simple batch script (.bat) to copy the file from a central share to the current users profile:

dir \\centralfileserver\path\imagelogo.jpg
if errorlevel = 1 goto exit
xcopy \\centralfileserver\path\imagelogo.jpg %USERPROFILE%\appdata\roaming\microsoft\imagelogo.jpg
:exit

Assign it as a logon script for all users via Group Policy

link|improve this answer
Copying files with the logonscript tends to increase the logontime. Also no errorhandling! Example: What happens when "centralfileserver" is not available? – Tom Jan 24 at 9:39
Nothing. Use ERRORLEVEL if you want error handling – Mathias R. Jessen Jan 24 at 16:38
Added a little error handling for the pleasure of @Tom ;) – Mathias R. Jessen Jan 24 at 17:26
1  
if exist \\centralfileserver\path\imagelogo.jpg xcopy... should also work. – Bryan Jan 24 at 20:24
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.