Scripts Thread, Script to copy a file or folder to multiple users Documents folder. in Coding and Web Development; Hi,
I am just trying to teach my self some basic scripts, am totally new to coding. What i am ...
31st January 2014, 11:48 AM #1
- Rep Power
Script to copy a file or folder to multiple users Documents folder.
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\JBloggs1 3\My Documents
\\fileserver\redirected$\Pupils\2013start\TBloggs1 3\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.
Last edited by Menov321; 31st January 2014 at 11:51 AM.
31st January 2014, 11:53 AM #2
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"
31st January 2014, 12:23 PM #3
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
2 Thanks to enjay:
IWDave (31st January 2014), Menov321 (31st January 2014)
31st January 2014, 02:41 PM #4
- Rep Power
thanks so much to sted and enjay... I tried enjays method and it worked a charm
3rd February 2014, 03:57 PM #5
- Rep Power
dsquery * domainroot -filter "(&(objectCategory=Person)(objectClass=User)(!(use rAccountControl:1.2.840.1135126.96.36.1993:=2))(homedi rectory=*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
By reggiep in forum Windows Server 2008 R2
Last Post: 23rd March 2012, 12:43 PM
By itgeek in forum MIS Systems
Last Post: 15th February 2011, 09:03 PM
By reggiep in forum How do you do....it?
Last Post: 11th February 2011, 05:36 PM
By itgeek in forum Scripts
Last Post: 1st December 2009, 03:38 PM
By tosca925 in forum Windows
Last Post: 20th October 2005, 07:48 PM
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)