Windows 7迁移用户配置文件

时间:2014-04-15 07:27:59

标签: windows windows-7 vbscript

我们正在尝试创建一个脚本,以便在因故障等更换PC的情况下迁移Windows 7中的每个用户配置文件。

我们一直在使用以下内容:

Dim fso 
Dim oFolder1, objFolder, oFolder
Dim path
Dim colFolders
Dim sDocsAndSettings 
Dim strDirectory

Set fso = createobject("Scripting.FileSystemObject")

'===========================================================
'CHANGE SDESTINATION FOLDER PATH HERE
sPath =  "C:\Backup"
'===========================================================
Set proFolder = fso.GetFolder(sPath)

'COPY FILES FROM USER PROFILES
sDocsAndSettings = "C:\Users\"   
Set colFolders = fso.GetFolder(sDocsAndSettings) 

For Each oFolder In colFolders.SubFolders
    Select Case LCase(oFolder.Name)
        Case "admin", "administrator", "newuser", "all users", "default user", "default user.original", "localservice", "networkservice"
            'LEAVE THE DEFAULT PROFILES ON THE MACHINE
        Case Else
            'MsgBox oFolder.Name            
            If fso.FolderExists(proFolder) Then
                strDirectory = proFolder & "\" & oFolder.Name 
                If fso.FolderExists(strDirectory) Then
                Else 
                    Set objFolder = fso.CreateFolder(strDirectory)
                End If

                'COPY USER PROFILE FOLDERS to Destination Folder
                fso.CopyFolder sDocsAndSettings & oFolder.Name & "\Favorites" , objFolder & "\", True
                fso.CopyFolder sDocsAndSettings & oFolder.Name & "\Documents" , objFolder & "\", True
                fso.CopyFolder sDocsAndSettings & oFolder.Name & "\Desktop" , objFolder & "\", True
            End If
    End Select 
Next

MsgBox "Backup has been completed successfully!"

Set fso = Nothing

我们似乎遇到了一个问题,即每个配置文件中的连接点(例如我的文档)都会出现问题,这会导致脚本出现权限错误,因为将My Documents行删除,脚本可以运行。任何想法,或者是否有更简单的脚本来迁移配置文件(我们需要能够迁移特定的子文件夹)。

0 个答案:

没有答案