?
Solved

Copy a file to all profile directories.

Posted on 2012-04-11
10
Medium Priority
?
230 Views
Last Modified: 2013-02-22
I have a preferences file that I need to copy to all active users' profile directory. I have a mixed Windows XP and Windows 7 environment. Not sure what the easiest way to do this would be.
0
Comment
Question by:drgleockler
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
  • +1
10 Comments
 
LVL 15

Expert Comment

by:wantabe2
ID: 37832356
Why not just create a network share on a file server & map each user to that directory with a login script or you could go to each computer & add the file to the pulic / all user directory.
0
 

Author Comment

by:drgleockler
ID: 37832373
Is there one script that would work for windows xp and windows 7? My scripting is a bit rusty....I have the file in a network share already.
0
 

Author Comment

by:drgleockler
ID: 37834665
Also, the file has to be added to the actual profiles on each pc not the public/all user directory.
0
WatchGuard's M Series Appliances - Miecom Approved

WatchGuard's newest M series appliances were put to the test by Miercom.  We had great results and outperformed all of our competitors in both stateless and stateful traffic throghput scenarios! Ready to see how your UTM appliance stacked up? Download the Miercom Report!

 
LVL 42

Expert Comment

by:kevinhsieh
ID: 37867440
How easy it is depends on where you need to have it in the profile structure. Can you please give the exact patch for Windows XP and Windows 7 users?

This can be done using group policy preferences, or a login script. There might be some WMI filters or other logic involved to determine the path to copy the file to. Whether or not you need to keep the file as an exact copy of the original, or it you just need to get it in the profile once, will also help determine the path to take with this.

It might be as simple as

copy \\server\share\path\file.ext %userprofile%\path
0
 
LVL 65

Expert Comment

by:RobSampson
ID: 37868418
You can use a script to determine the operating system, and therefore the correct path required, for situations where on XP you need to copy a file to
%userprofile%\Application Data\AppName

or on Windows 7 you need to copy a file to
%userprofile%\AppData\Roaming\AppName

Let us know the path that you need to copy the file to, and also whether you want it overwritten at each login (as kevinhsieh has noted), and we can help further.

Regards

Rob.
0
 

Author Comment

by:drgleockler
ID: 37914876
The file is a preferences file that needs to go in the root of the user profile. so for windows 7 it needs to go to C:\Users\%profilename%\ and for Windows XP C:\Documents and Settings\%profilename%.

For some users it will be the first time the file has been added...for other users it needs to overwrite the current preference file.

If you need anymore information, please let me know. I had been away for training...sorry I didn't get back to you.
0
 
LVL 42

Accepted Solution

by:
kevinhsieh earned 2000 total points
ID: 37915678
If it literally just goes in the profile directory, this is all you need as a login script set via GPO:

copy /y \\server\share\path\file.ext %userprofile%\filename.ext
0
 
LVL 65

Expert Comment

by:RobSampson
ID: 37917157
kevinhsieh is right, if it goes in the root of the profile, then %userprofile% corresponds to each path you have listed whether you're on XP or Windows 7.  This is the VBS version of that.

Regards,

Rob.

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objShell = CreateObject("WScript.Shell")
strFileToCopy = "\\server\share\settings.ini"
strUserProfile = objShell.ExpandEnvironmentStrings("%userprofile%")
objFSO.CopyFile strFileToCopy, strUserProfile & "\", True

Open in new window

0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Popular third-party chat platforms like Slack, Discord, and Telegram are just a few of the many new productivity applications that are being hijacked by cybercriminals to create command-and-control (C&C) communications infrastructures for their malw…
Backups and Disaster RecoveryIn this post, we’ll look at strategies for backups and disaster recovery.
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question