Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question
add comment

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.

share|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 '12 at 18:34
add comment

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

share|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 '12 at 9:39
    
Nothing. Use ERRORLEVEL if you want error handling –  Mathias R. Jessen Jan 24 '12 at 16:38
    
Added a little error handling for the pleasure of @Tom ;) –  Mathias R. Jessen Jan 24 '12 at 17:26
1  
if exist \\centralfileserver\path\imagelogo.jpg xcopy... should also work. –  Bryan Jan 24 '12 at 20:24
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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