Solved

Backup user domain profile locally

Posted on 2010-08-23
8
376 Views
Last Modified: 2012-05-10
hi experts,

with reference to
http://www.experts-exchange.com/OS/Microsoft_Operating_Systems/Windows/XP/Q_23181552.html

i would like to achieve the same objective as the author (without using roaming profile), but with a gpo login script in vbs. Let me reiterate the manual steps:

1.  Open regedit, navigate to HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList
2.  Locate and export the registry key and subkeys matching the user's folder to the local backup location in D drive.  
3.  Copy the user's folder from Documents and Settings to the local backup location in D drive



 
' Desktop Backup & My Documents Redirect Registry related methods.

Dim strUserID 
Dim WSHShell

Set WSHNetwork = WScript.CreateObject("WScript.Network")
Set WSHShell = WScript.CreateObject("WScript.Shell")

strUserID = WSHNetwork.UserName

' My Documents Redirect
WSHShell.RegDelete "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\Personal"
WSHShell.RegWrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\Personal", "D:\" & strUserID & "\My Documents"
WSHShell.RegDelete "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\Favorites"
WSHShell.RegWrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\Favorites", "D:\" & strUserID & "\My Documents\Favorites"

' Desktop Backup
<insert code here>

Open in new window

0
Comment
Question by:kenny_klbn
  • 3
  • 3
  • 2
8 Comments
 
LVL 2

Expert Comment

by:Orgrim
ID: 33511823
Hi,

Try this:

Const OverWriteFiles = True
Set objFSO = WScript.CreateObject("Scripting.FileSystemObject")
objFSO.CopyFolder "C:\Documents and Settings\" & strUserID , "D:\Backup\" & strUserID, OverWriteFiles

Bye
0
 

Author Comment

by:kenny_klbn
ID: 33517033
hi Orgrim,

how do i translate these steps into code?

1.  Open regedit, navigate to HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList
2.  Locate and export the registry key and subkeys matching the user's folder to the local backup location in D drive.  
0
 

Author Comment

by:kenny_klbn
ID: 33518727
hi

ive specified "Desktop" in the following syntax but ran with error. please advise.

objFSO.CopyFolder "C:\Documents and Settings\" & strUserID & "\Desktop", "D:\DesktopBackup\" & strUserID, OverWriteFiles
0
 
LVL 6

Expert Comment

by:dax_bad
ID: 33518779
Be carefull using the copy methods (copy, copyFile,CopyFolder) of the FileSystemObjects in VBscript... the first error they enter (ie. locked file) will terminate the copy process.

/Daniel
0
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 

Author Comment

by:kenny_klbn
ID: 33518801
hi Daniel,

the script will run at user logon, will this create "locked file" situation?
0
 
LVL 6

Assisted Solution

by:dax_bad
dax_bad earned 200 total points
ID: 33519017
Well im not really sure if there will be any locked files during login, but i think its best to focus the copy on file level or call robocopy and let it do the actual copying.

With regards to the registry keys, here's two articles at EE about exporting registry keys:
http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_23641876.html
http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_23045038.html

cheers
Daniel
0
 
LVL 2

Accepted Solution

by:
Orgrim earned 300 total points
ID: 33523202
Hi,

1) Your question about saving the registry
It would be a bad way to use the regread method from thw WSHShell as you would have to go through every node of the registry. Try this approach instead
http://searchwindowsserver.techtarget.com/tip/0,289483,sid68_gci1039573,00.html

2) "Desktop" Syntax
I used your variable strUserID as you put the person name earlier in your script. Make you if you run mine that you put a value into it. Like this:

Const OverWriteFiles = True
Dim strUserID
Set WSHNetwork = WScript.CreateObject("WScript.Network")
strUserID = WSHNetwork.UserName

Set objFSO = WScript.CreateObject("Scripting.FileSystemObject")
objFSO.CopyFolder "C:\Documents and Settings\" & strUserID & "\Desktop", "D:\Backup\" & strUserID, OverWriteFiles

Bye
0
 
LVL 6

Expert Comment

by:dax_bad
ID: 33528874
Hey Ogrim

The CopyFolder methos of the fileSystemObject will terminate on the first locked file it encounters and thus terminate the copy process prematurely, there's not way of preventing that with that method, only way is to cycle through each file and use the error msgs to handle and retry the copy process. Thats why i recommended calling a 3rd party copy tool and handle the response from that.

/Daniel
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

If like me you are one who spends a lot of time working and scripting with cmd.exe, sometimes it is handy to be able to quickly view a calendar for a given month and year. This script will quickly do just that!  Save the code posted below to a .bat …
How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
This tutorial will walk an individual through the steps necessary to join and promote the first Windows Server 2012 domain controller into an Active Directory environment running on Windows Server 2008. Determine the location of the FSMO roles by lo…
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles to another domain controller. Log onto the new domain controller with a user account t…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now