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

Thanks
abhijitm00Asked:
Who is Participating?
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.

McKnifeCommented:
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.
0
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.
0
Jose Gabriel Ortega CEE Solution Guide - CEO Faru Bonon ITCommented:
Powershell solution
$source="C:\source\test.ini"
$destination="C:\users\$env:USERNAME\Appdata\SAP\Roaming"
Copy-Item -Path "$source" -Destination "$destination"

Open in new window

0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

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

Thanks
0
Jose Gabriel Ortega CEE Solution Guide - CEO Faru Bonon ITCommented:
Create a login script (powershell)
Here's the steps:
https://technet.microsoft.com/en-us/library/ee431705(v=ws.10).aspx

$source="C:\source\test.ini"
$destination="C:\users\$env:USERNAME\Appdata\Roaming\SAP"
Copy-Item -Path "$source" -Destination "$destination"

Open in new window

0

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
0
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
1
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
0
Shaun VermaakTechnical Specialist/DeveloperCommented:
...or if you have Active Directory you can deploy this as a file or INI
52.png
0
McKnifeCommented:
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 :-|
1
Jose Gabriel Ortega CEE Solution Guide - CEO Faru Bonon ITCommented:
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
0
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.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.