2

I want to copy iTunesPrefs.xml file for all the users, who have ever logged on to the PC, under the above mentioned location (for iTunes installation). If I run the batch file as a current user, I can only write to my AppData Folder. Also, if I do copy the file to "Default" User; only the new staff who are logging in will get the required settings. I have a system account, which can log onto all the User folders. So, I want it to be copied across all the currently existing profiles. For e.g for following users:

  1. Charlie : C:\Users\Charlie\AppData\Local
  2. Adam : C:\Users\Adam\AppData\Local
  3. Gregg : C:\Users\Gregg\AppData\Local
demongolem
  • 9,474
  • 36
  • 90
  • 105
user3839914
  • 83
  • 1
  • 2
  • 9

2 Answers2

1

Something like this would work. Assuming you have admin rights to the other user folders. Its very down and dirty, and will throw an error if the appdata\local\ directory does not exist.

When you run this in the C:\users\ directory, it attempts to do a copy on every profile in the C:\users\ directory.

FOR /d %G in ("*") DO copy C:\temp\iTunesPrefs.xml C:\users\%G\appdata\local\
Gwenc37
  • 2,064
  • 7
  • 18
  • 22
DandC
  • 126
  • 3
  • I have a co-worker with an AutoIT script that does something very similar. But he has built a GUI that gives the user control over some things. I will see if he wouldn't mind publishing to GitHub. – DandC Jul 29 '16 at 04:57
1
for /f %a in ('dir c:\users /b') do xcopy C:\temp\test123.txt c:\users\%a\appdata\local
Das_Geek
  • 2,775
  • 7
  • 20
  • 26
Gabi
  • 21
  • 1