Solved

Backup user domain profile locally

Posted on 2010-08-23
8
385 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
  • 2
8 Comments
 
LVL 2

Expert Comment

by:Remi Gelinas
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
Office 365 Training for IT Pros

Learn how to provision tenants, synchronize on-premise Active Directory, implement Single Sign-On, customize Office deployment, and protect your organization with eDiscovery and DLP policies.  Only from Platform Scholar.

 
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
 

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:
Remi Gelinas 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

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

While rebooting windows server 2003 server , it's showing "active directory rebuilding indices please wait" at startup. It took a little while for this process to complete and once we logged on not all the services were started so another reboot is …
This article explains the steps required to use the default Photos screensaver to display branding/corporate images
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…
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

752 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