Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Backup user domain profile locally

Posted on 2010-08-23
8
Medium Priority
?
388 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
Veeam Task Manager for Hyper-V

Task Manager for Hyper-V provides critical information that allows you to monitor Hyper-V performance by displaying real-time views of CPU and memory at the individual VM-level, so you can quickly identify which VMs are using host resources.

 
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 800 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 1200 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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

Compliance and data security require steps be taken to prevent unauthorized users from copying data.  Here's one method to prevent data theft via USB drives (and writable optical media).
How to deal with a specific error when using the Enable-RemoteMailbox cmdlet to create a mailbox in the cloud-based service, for an existing user in an on-premises Active Directory.
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 …
Suggested Courses

824 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