drgleockler
asked on
Copy a file to all profile directories.
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.
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.
ASKER
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.
ASKER
Also, the file has to be added to the actual profiles on each pc not the public/all user directory.
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.e xt %userprofile%\path
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.e
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\Roam ing\AppNam e
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.
%userprofile%\Application Data\AppName
or on Windows 7 you need to copy a file to
%userprofile%\AppData\Roam
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.
ASKER
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.
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.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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.
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