Script to copy .ini file to a new user's Appdata folder

Hi Experts,

Is there a script or a process where an .ini file from a folder under C:\ in copied into the user's C:\Users\<user>\Appdata\SAP\Roaming folder?

This needs to be done for Win 7 and Win 10 machines, so anytime a new user logs onto the machine and his/her profile is created this file gets copied over to the above mentioned folder path

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

copy c:\somefolder\some.ini %userprofile%\appdata\SAP\roaming /y

Open in new window

(used as a logon script)
But please check the target path, I guess you got it wrong and it's ...\roaming\spa instead.
Lee W, MVPTechnology and Business Process AdvisorCommented:
You're not being very specific so the best I can offer is this:

copy "c:\Folder With\the.ini" "%appdata%\sap\roaming" /y

Open in new window

If you want to provide EXACT file paths and names, including which AppData folder (Local, LocalLow, or Roaming), we can give you a more specific answer.
Jose Gabriel Ortega CastroCEO Faru Bonon IT - EE Solution ExpertCommented:
Powershell solution
Copy-Item -Path "$source" -Destination "$destination"

Open in new window

Acronis True Image 2019 just released!

Create a reliable backup. Make sure you always have dependable copies of your data so you can restore your entire system or individual files.

abhijitm00Author Commented:
Thank you all for responding, yes the path is incorrect it should be \roaming\sap

How will the bath/powershell run when a new user logs in? I am looking to see if this can be automated so that any new user that logs onto a PC gets the new file

Jose Gabriel Ortega CastroCEO Faru Bonon IT - EE Solution ExpertCommented:
Create a login script (powershell)
Here's the steps:

Copy-Item -Path "$source" -Destination "$destination"

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
abhijitm00Author Commented:
Thanks Jose. I will try that and update
MacleanSystem EngineerCommented:
Would it not be a lot easier to use a group policy for this perhaps?

Create a GPO and name it as desired.
Tell it to create the folder if the folder does not exist by default
Then tell it ro replace or copy the *.ini from source to destination
Link the GPO to a test OU with a test user in it
If working, link to user OU required
I could re-write the procedure, but this example here shows the gist of what I mean
Mal OsborneAlpha GeekCommented:
Here is a another way of approaching that problem, which seems better to me.

When a new user logs onto a machine for the first time, Windows copies the "default" profile to create a new user profile. Thus, if you just add the .INI file in the appropriate folder, it will be copied over and included in any new profile. For Windows 10, this would be C:\Users\default\Appdata\SAP\Roaming folder
Shaun VermaakTechnical SpecialistCommented:
...or if you have Active Directory you can deploy this as a file or INI
The author has been shown both possible methods, GPO logon script and GPP file items. There is no best method. Both are easy so include all suggestions when distributing points. Be aware that point distribution does not need to be 50% for me and the rest gets a share of the other 50% - you can edit that when closing.

I don't mind. I only mind questions being constantly abandoned by authors :-|
Jose Gabriel Ortega CastroCEO Faru Bonon IT - EE Solution ExpertCommented:
Both method are way to do the job. So it's nvm which method should try or take the author. He would have his reasons to do it the way he asked initially
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows OS

From novice to tech pro — start learning today.