Windows Thread, Copying files off PCs in Technical; Hello all,
I need to copy a specific folder off a number of different PCs. I would like to do ...
19th March 2010, 03:51 PM #1
Copying files off PCs
I need to copy a specific folder off a number of different PCs. I would like to do this via a script if possible.
The only problem I can see is that the folder is in
C:\documents and settings\user name\...rest of string...
How would I write something that gets me through that "user name" folder into the directory below, regardless of what that "user name" folder is named?
Last edited by Robot; 19th March 2010 at 03:55 PM.
IDG Tech News
19th March 2010, 03:55 PM #2
- Rep Power
19th March 2010, 03:57 PM #3
%username% returns the logged on username though, it won't walk through directories in the documents and settings folder. Are you going to be running the script manually at each PC or do you want to do it remotely?
You'll want something like a for loop in the script to walk through the directories -
cd C:\documents and settings\
for %%I /D in (*) do copy "C:\documents and settings\%%I\yourstring\yourfile.txt" "\\server\folder"
Thanks to OutToLunch from:
19th March 2010, 03:59 PM #4
I would be wanting to run it remotely but only to select PCs in the domain, so would also need to target them somehow.
Originally Posted by OutToLunch
19th March 2010, 05:21 PM #5
something like this? Not sure if you have a known list of PCs (this assumes you have an it's in a plain text file) or if you're going to query all PCs in an OU in AD or whatever but I hope this gets you started.
'what's the folder to look for
'where do you want it copying to
'simple list of PCs; read it and store in array
do while not oFile.atendofstream
iComputers=iComputers + 1
redim preserve sComputers(iComputers)
for each sComputer in sComputers
if sComputer<>"" then
'get the root of D&S
sPath="\\" & sComputer & "\c$\documents and settings\"
for each oSubFolder in oFolder.subfolders
'look at each user folder
if ofso.folderexists(sPath & oSubFolder.Name & "\" & sFolderName) then
'the folder we want exists so make a suitable folder on the destination machine - first for computer
if not ofso.folderexists(sDestination & sComputer) then ofso.createfolder sDestination & sComputer
'and now for user
if not ofso.folderexists(sDestination & sComputer & "\" & oSubFolder.Name) then ofso.createfolder sDestination & sComputer & "\" & oSubFolder.Name
ofso.copyfolder sPath & oSubFolder.Name & "\" & sFolderName,sDestination & sComputer & "\" & oSubFolder.Name & "\"
Thanks to srochford from:
21st March 2010, 12:06 AM #6
Thanks very much! I will have a look at this on Monday
By randle in forum Wireless Networks
Last Post: 25th March 2009, 12:27 AM
By DeanD in forum Windows
Last Post: 13th April 2008, 05:26 PM
By torledo in forum Windows
Last Post: 18th March 2008, 03:28 PM
By SimpleSi in forum Windows
Last Post: 3rd March 2008, 03:29 PM
By enjay in forum Windows Vista
Last Post: 26th September 2007, 10:41 AM
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)