Solved

Backup user domain profile locally

Posted on 2010-08-23
8
386 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
Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

 
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

Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

Question has a verified solution.

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

Active Directory security has been a hot topic of late, and for good reason. With 90% of the world’s organization using this system to manage access to all parts of their IT infrastructure, knowing how to protect against threats and keep vulnerabil…
Had a business requirement to store the mobile number in an environmental variable. This is just a quick article on how this was done.
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 configuring their Windows Server 2012 domain controller to synchronize its time with a trusted, external resource. Use Google, Bing, or other preferred search engine to locate trusted NTP …

622 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