Menov321 Posted January 31, 2014 Posted January 31, 2014 (edited) Hi, I am just trying to teach my self some basic scripts, am totally new to coding. What i am looking to do is to comprise a script to copy files or folder from one location to all users "my documents" folder. currently this is on windows 2008 r2 platform. the files needed to be copied would be on a server eg \\fileserver\Filefolder the folders needing the files are laid out like this \\fileserver\redirected$\Pupils\2013start\JBloggs13\My Documents \\fileserver\redirected$\Pupils\2013start\TBloggs13\My Documents so my problem is how do i get the script to copy to all the usernames "my documents folder" without manually specifying the unc path of all of them. Also does the fact there is a space in my documents affect the layout of the script. the users dont have a home path specified in AD, they are redirected through Group Policy. Edited January 31, 2014 by Menov321
sted Posted January 31, 2014 Posted January 31, 2014 might be easier to use gpp and tell it to copy file from a to my documents for the group 2013 or just use a logon script copy "\\server\share\source.txt" "%homedrive%\my documents\source.txt"
enjay Posted January 31, 2014 Posted January 31, 2014 I had to do this recently. Here's (roughly) what I did: Open CMD prompt Type dir >names.txt to get a list of all the students' folders Open the text file in Excel Use "Concatenate" command to create a load of commands which read something like copy C:\Folders\Files\*.* D:\Users\Students\%Names%\ Copy and paste the Excel data into Notebook Save as .bat Run it 2
Menov321 Posted January 31, 2014 Author Posted January 31, 2014 thanks so much to sted and enjay... I tried enjays method and it worked a charm
jklight Posted February 3, 2014 Posted February 3, 2014 dsquery * domainroot -filter "(&(objectCategory=Person)(objectClass=User)(!(userAccountControl:1.2.840.113556.1.4.803:=2))(homedirectory=*server1*))" -limit 500 | dsget user -hmdir -samid -c > out.txt for /f "skip=1 tokens=1,2" %%a in (out.txt) do copy \\server\share\file %%a\folder\file
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now