Solved

Backup user domain profile locally

Posted on 2010-08-23
8
383 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: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
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 
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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

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 …
In-place Upgrading Dirsync to Azure AD Connect
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 from a Windows Server 2008 domain controller to a Windows Server 2012 domain controlle…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

861 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