Need to Copy a Pref file to ALL users.

I’m trying to write a script that copies a Preference file into every users Preference Folder on our Xserve.

So far I’ve managed to copy the file into 1 user at a time (I’ve got 100+ still to do). I’m using the “system.osax” addition for the Password part of the script.

Here’s my script so far:
set theSourceFile to (quoted form of POSIX path of (“Macintosh HD:Users:benr:Desktop:thePref:”)) & “*”

set thePrefsFolder to (quoted form of POSIX path of (choose folder)) & “Library/Preferences/”

set thePassword to (askPassword with prompt) as string
set command to "ditto -rsrc "
do shell script command & theSourceFile & space & thePrefsFolder password thePassword with administrator privileges

What I wait to be able to do is either select the Main folder where the Users are stored or select multiple Users and copy the file into every preference folder.

Hope someone can help.
Ben.

I answered on Apple’s forum (I happened to visit it before coming here) but, for the benefit of others with similar needs, I’ll post the code here since Apple prunes its forums.
I said:

“Something along these lines might work or it might, at least, provide the basis for something that does work. Assuming that your code is solid, it should (untested) copy the file to the prefs folder of every user.”

 set users_fol to path to users folder
 set users_ to list folder users_fol without invisibles
 set command to "ditto -rsrc "
 set theSourceFile to (quoted form of POSIX path of ¬
  ("Macintosh HD:Users:benr:Desktop:thePref:")) & "*"
 set thePassword to (askPassword with prompt) as string

 repeat with user_ in users_
  set user_pref_path to quoted form of POSIX path of ¬
   ((users_fol as Unicode text) & user_ & ":Library:Preferences:")
  do shell script command & theSourceFile & space & user_pref_path ¬
   password thePassword with administrator privileges
 end repeat

Ben replied:

"Script works really well. I’ve changed the first line to:

set users_fol to (choose folder)

To allow me to choose which group of Users I want to copy to."

– Rob