topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • Tuesday March 19, 2024, 5:34 am
  • Proudly celebrating 15+ years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: IDEA: My Documents, Desktop and Favourites Backup for all Users on a PC  (Read 9472 times)

scottchamings

  • Supporting Member
  • Joined in 2008
  • **
  • default avatar
  • Posts: 8
    • View Profile
    • Donate to Member
Hi,

I would love some code that will go through C:\Documents and Settings and for each user copy their My Documents, Favorites and Desktop folder to another folder structure retaining their username.

eg

copy C:\Documents and Settings\Scott\My Documents to %Path I specify%\Scott\My Documents

I often need to do this and manual copying is just so slow and clumbersome...

Thanks

Scott


belkira

  • Member
  • Joined in 2006
  • **
  • Posts: 52
    • View Profile
    • Donate to Member
Re: IDEA: My Documents, Desktop and Favourites Backup for all Users on a PC
« Reply #1 on: September 04, 2008, 10:32 AM »
Scott,

Might give this a try. I have been using it for a while and it works very well.

http://www.karenware...ols/ptreplicator.asp

-belkira

scottchamings

  • Supporting Member
  • Joined in 2008
  • **
  • default avatar
  • Posts: 8
    • View Profile
    • Donate to Member
Re: IDEA: My Documents, Desktop and Favourites Backup for all Users on a PC
« Reply #2 on: September 04, 2008, 11:09 AM »
This is close but not quite.  I need something that does not need me to select the folders under each of the users names or even know them in advance.

Basically need it to parse all the user ids, start a copy but keep the path structure intact and only copy the My Documents, Favorites and Desktop folders and down for each of the users, even though there might be heaps more folders under each user (Temp etc) which I dont want...

VideoInPicture

  • Honorary Member
  • Joined in 2008
  • **
  • Posts: 467
    • View Profile
    • Circle Dock
    • Donate to Member
Re: IDEA: My Documents, Desktop and Favourites Backup for all Users on a PC
« Reply #3 on: September 04, 2008, 02:48 PM »
Attached is a VB Script file that will do what you specified. Just double-click the .vbs file and it will automatically copy the selected folders. Change the strDestination path to change where the copied files are placed.

From your other thread about file copying, I assume you are going to be using this in a corporate environment so a VB Script file is your best choice since it will run on all computers without the need for more software. See the comments in the code for more details.

Code: Visual Basic [Select]
  1. ' CopyUserFiles.vbs
  2. ' VBScript for copying the Document and User files to another directory
  3. ' Coded for Windows XP but can be adapted for 2000 / Vista by changing
  4. ' FavoritesFolder, DesktopFolder, MyDocumentsFolder, strFilePath, and strDestination to suit your needs
  5. '
  6. ' Program runs silently while copying. It may take a while to copy large files.
  7. ' A messagebox will pop up when finished.
  8. '
  9. ' Author: Eric Wong http://circledock.wikidot.com
  10. ' Version 1.0 - 4th September 2008
  11. ' ----------------------------------------------------------
  12.  
  13. Option Explicit
  14.  
  15. Dim objFSO_DIR, objFolder, objCopyFolder, colSubfolders, objSubfolder
  16. Dim objFSO, objFileCopy
  17. Dim strFilePath, strDestination
  18. Dim fileChecker, objShell
  19. Const OverWriteFiles = True
  20.  
  21. Const FavoritesFolder = "\Favorites"
  22. Const DesktopFolder = "\Desktop"
  23. Const MyDocumentsFolder = "\My Documents"
  24.  
  25. strFilePath = "C:\Documents and Settings"
  26. strDestination ="C:\New Documents and Settings"
  27.  
  28. Set objFSO = CreateObject("Scripting.FileSystemObject")
  29. Set fileChecker = CreateObject("Scripting.FileSystemObject")
  30. Set objShell = CreateObject("Shell.Application")
  31. 'Set objCopyFolder = CreateObject("Shell.Application")
  32.  
  33. objFSO.CreateFolder(strDestination)
  34.  
  35. Set objFSO_DIR = CreateObject("Scripting.FileSystemObject")
  36. Set objFolder = objFSO_DIR.GetFolder(strFilePath)
  37. Set colSubfolders = objFolder.Subfolders
  38.  
  39. 'This is the core of the file copying process
  40. For Each objSubfolder in colSubfolders
  41.     Set objFolder = objFSO.CreateFolder(strDestination & "\" & objSubfolder.Name)  
  42.  
  43.     If fileChecker.FolderExists(objSubfolder & FavoritesFolder) = True Then
  44.        fileChecker.CopyFolder objSubfolder & FavoritesFolder, objFolder & FavoritesFolder, OverWriteFiles
  45.     End If
  46.  
  47.     If fileChecker.FolderExists(objSubfolder & DesktopFolder) = True Then
  48.        fileChecker.CopyFolder objSubfolder & DesktopFolder, objFolder & DesktopFolder, OverWriteFiles
  49.     End If
  50.  
  51.     If fileChecker.FolderExists(objSubfolder & MyDocumentsFolder) = True Then
  52.        fileChecker.CopyFolder objSubfolder & MyDocumentsFolder, objFolder & MyDocumentsFolder, OverWriteFiles
  53.     End If
  54. Next
  55.  
  56. WSCript.Echo "Finished copying selected folders from " & strFilePath & " to " & strDestination
  57. Wscript.Quit
Author of Circle Dock: http://circledock.wikidot.com
Author of Video In Picture: http://videoinpicture.wikidot.com
Author of Webcam Signature: http://webcamsignature.wikidot.com
Author of Easy Unicode Paster: http://easyunicodepaster.wikidot.com

scottchamings

  • Supporting Member
  • Joined in 2008
  • **
  • default avatar
  • Posts: 8
    • View Profile
    • Donate to Member
Re: IDEA: My Documents, Desktop and Favourites Backup for all Users on a PC
« Reply #4 on: September 04, 2008, 05:19 PM »
awesome, thanks, will try out later today on a couple of PCs I need to reimage....

VideoInPicture

  • Honorary Member
  • Joined in 2008
  • **
  • Posts: 467
    • View Profile
    • Circle Dock
    • Donate to Member
Re: IDEA: My Documents, Desktop and Favourites Backup for all Users on a PC
« Reply #5 on: September 04, 2008, 05:41 PM »
Just a note: ensure that the folder you specify to copy to doesn't already exist because the program is not set up to overwrite an existing folder and will throw an error. It can be modified to overwrite an existing folder if that is what the goal is.
Author of Circle Dock: http://circledock.wikidot.com
Author of Video In Picture: http://videoinpicture.wikidot.com
Author of Webcam Signature: http://webcamsignature.wikidot.com
Author of Easy Unicode Paster: http://easyunicodepaster.wikidot.com

lanux128

  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 6,277
    • View Profile
    • Donate to Member
Re: IDEA: My Documents, Desktop and Favourites Backup for all Users on a PC
« Reply #6 on: September 04, 2008, 08:29 PM »
cool script! i was going to suggest XXCOPY but i guess with Eric's script, one need not to fiddle with switches. :)