Copy User Profile with VBS Script problem

rgaspar

New Member
Hello,

Can you help me?
I tried to copy a profile to another folder by vbscript, but folder Documents not copy complete. Why?
I now this forum not write or speak language vbscript but i search google, etc..etc and not have solution for this problem.

My code Vbscript.vbs

Code:
dim wshell, strusername, filesys
Const OverwriteExisting = TRUE
Set WshShell = CreateObject("WScript.Shell")
Set WshEnv = WshShell.Environment("SYSTEM")
Set filesys = CreateObject("Scripting.FileSystemObject")
StrUsername = wshShell.ExpandEnvironmentStrings("%username%")
msgbox strUsername
Call BackupC
Sub BackupC
If filesys.FolderExists ("C:\Dados\" & StrUsername & ".$$$") Then
If msgbox ("There is already a folder called C:\Dados\" & StrUsername & ".$$$" & ". Do you want to proceed?",4, "Image Customization") = 7 Then
Exit Sub
Else
filesys.DeleteFolder "C:\Dados\" & StrUsername & ".$$$", TRUE
filesys.CreateFolder ("C:\Dados\" & StrUsername & ".$$$")
End If
Else
filesys.CreateFolder ("C:\Dados\" & StrUsername & ".$$$")
End If
 
If filesys.FolderExists ("C:\Users\" & StrUsername) Then
'**** DESKTOP ****
If filesys.FolderExists ("C:\Users\" & StrUsername & "\Desktop") Then
filesys.CreateFolder ("C:\Dados\" & StrUsername & ".$$$" & "\Desktop")
filesys.CopyFolder "C:\Users\" & StrUsername & "\Desktop", "C:\Dados\" & StrUsername & ".$$$" & "\Desktop", TRUE
End If
'**** QUICK LAUNCH ****
If filesys.FolderExists ("C:\Users\" & StrUsername & "\AppData\Roaming\Microsoft\Internet Explorer\Quick Launch") Then
filesys.CreateFolder ("C:\Dados\" & StrUsername & ".$$$" & "\QuickLinks")
filesys.CopyFolder "C:\Users\" & StrUsername & "\AppData\Roaming\Microsoft\Internet Explorer\Quick Launch", "C:\Dados\" & StrUsername & ".$$$" & "\QuickLinks", TRUE
End If
'**** FAVORITES ****
If filesys.FolderExists ("C:\Users\" & StrUsername & "\Favorites") Then
filesys.CreateFolder ("C:\Dados\" & StrUsername & ".$$$" & "\Favorites")
filesys.CopyFolder "C:\Users\" & StrUsername & "\Favorites", "C:\Dados\" & StrUsername & ".$$$" & "\Favorites", TRUE
End If
'**** SIGNATURES ****
If filesys.FolderExists ("C:\Users\" & StrUsername & "\AppData\Roaming\Microsoft\Signatures") Then
filesys.CreateFolder ("C:\Dados\" & StrUsername & ".$$$" & "\Signatures")
filesys.CopyFolder "C:\Users\" & StrUsername & "\AppData\Roaming\Microsoft\Signatures", "C:\Dados\" & StrUsername & ".$$$" & "\Signatures", TRUE
End If
'**** CRIA APENAS O FOLDER TEMPLATES ****
filesys.CreateFolder ("C:\Dados\" & StrUsername & ".$$$" & "\Templates")
'**** COPIA O FICHEIRO PERSONAL PARA O FOLDER TEMPLATES ****
If filesys.FileExists ("C:\Users\" & StrUsername & "\AppData\Roaming\Microsoft\Excel\XLSTART\Personal.xls") Then
filesys.CopyFile "C:\Users\" & StrUsername & "\AppData\Roaming\Microsoft\Excel\XLSTART\Personal.xls", "C:\Dados\" & StrUsername & ".$$$" & "\Templates\", TRUE
End If
'**** COPIA O FICHEIRO NORMAL.DOT PARA O FOLDER TEMPLATES ****
If filesys.FileExists ("C:\Users\" & StrUsername & "\AppData\Roaming\Microsoft\Templates\Normal.dotm") Then
filesys.CopyFile "C:\Users\" & StrUsername & "\AppData\Roaming\Microsoft\Templates\Normal.dotm", "C:\Dados\" & StrUsername & ".$$$" & "\Templates\", TRUE
End If
'**** COPIA O FICHEIRO AUTOTEMP.DOT PARA O FOLDER TEMPLATES ****
If filesys.FileExists ("C:\Users\" & StrUsername & "\AppData\Roaming\Microsoft\Templates\AUTOTEMP.DOT") Then
filesys.CopyFile "C:\Users\" & StrUsername & "\AppData\Roaming\Microsoft\Templates\AUTOTEMP.DOT", "C:\Dados\" & StrUsername & ".$$$" & "\Templates\", TRUE
End If
'**** CONTACTS ****
If filesys.FolderExists ("C:\Users\" & StrUsername & "\Contacts") Then
filesys.CreateFolder ("C:\Dados\" & StrUsername & ".$$$" & "\Contacts")
filesys.CopyFolder "C:\Users\" & StrUsername & "\Contacts", "C:\Dados\" & StrUsername & ".$$$" & "\Contacts", TRUE
End If
'**** LINKS ****
If filesys.FolderExists ("C:\Users\" & StrUsername & "\Links") Then
filesys.CreateFolder ("C:\Dados\" & StrUsername & ".$$$" & "\Links")
filesys.CopyFolder "C:\Users\" & StrUsername & "\Links", "C:\Dados\" & StrUsername & ".$$$" & "\Links", TRUE
End If
'**** MUSIC ****
If filesys.FolderExists ("C:\Users\" & StrUsername & "\Music") Then
filesys.CreateFolder ("C:\Dados\" & StrUsername & ".$$$" & "\Music")
filesys.CopyFolder "C:\Users\" & StrUsername & "\Music", "C:\Dados\" & StrUsername & ".$$$" & "\Music", TRUE
End If
'**** PICTURES ****
If filesys.FolderExists ("C:\Users\" & StrUsername & "\Pictures") Then
filesys.CreateFolder ("C:\Dados\" & StrUsername & ".$$$" & "\Pictures")
filesys.CopyFolder "C:\Users\" & StrUsername & "\Pictures", "C:\Dados\" & StrUsername & ".$$$" & "\Pictures", TRUE
End If
'**** VIDEOS ****
If filesys.FolderExists ("C:\Users\" & StrUsername & "\Videos") Then
filesys.CreateFolder ("C:\Dados\" & StrUsername & ".$$$" & "\Videos")
filesys.CopyFolder "C:\Users\" & StrUsername & "\Videos", "C:\Dados\" & StrUsername & ".$$$" & "\Videos", TRUE
End If
'**** DOCUMENTS ****
If filesys.FolderExists ("C:\Users\" & StrUsername & "\Documents") Then
filesys.CreateFolder ("C:\Dados\" & StrUsername & ".$$$" & "\Documents")
filesys.CopyFolder "C:\Users\" & StrUsername & "\Documents", "C:\Dados\" & StrUsername & ".$$$" & "\Documents", OverwriteExisting
End If
End If
End Sub
msgbox "done"

Thanks......
 

My Computer

System One

  • Memory
    4Gb
Hi, rgaspar, and welcome to the forums.

It is possible you have system files in the documents folder that are not allowing a full copy to process - have you verified that you can manually copy the folder?
 

My Computers

System One System Two

  • Operating System
    Windows 10 Pro X64 Insider Preview (Skip Ahead) latest build
    Manufacturer/Model
    The Beast Model V (homebrew)
    CPU
    Intel Core i7 965 EE @ 3.6 GHz
    Motherboard
    eVGA X58 Classified 3 (141-GT-E770-A1)
    Memory
    3 * Mushkin 998981 Redline Enhanced triple channel DDR3 4 GB CL7 DDR3 1600 MHz (PC3-12800)
    Graphics Card(s)
    eVGA GeForce GTX 970 SSC ACX 2.0 (04G-P4-3979-KB)
    Sound Card
    Realtek HD Audio (onboard)
    Monitor(s) Displays
    2 * Lenovo LT2323pwA Widescreeen
    Screen Resolution
    2 * 1920 x 1080
    Hard Drives
    SanDisk Ultra SDSSDHII-960G-G25 960 GB SATA III SSD (System)
    Crucial MX100 CT256MX100SSD1 256GB SATA III SSD (User Tree)
    2 * Seagate Barracuda 7200.12 ST31000528AS 1TB 7200 RPM SATA II Mech. HD
    Seagate ST1500DL001-9VT15L Barracuda 7200.12 1.5 TB S
    PSU
    Thermaltake Black Widow TX TR2 850W 80+ Bronze Semi-Mod ATX
    Case
    ThermalTake Level 10 GT (Black)
    Cooling
    Corsair H100 (CPU, dual 140 mm fans on radiator) + Air (2 *
    Keyboard
    Logitech G15 (gen 2)
    Mouse
    Logitech MX Master (shared)
    Internet Speed
    AT&T Lightspeed Gigabit duplex
  • Operating System
    Sabayon Linux (current, weekly updates, 5.1.x kernel)
    Manufacturer/Model
    Lenovo ThinkPad E545
    CPU
    AMD A6-5350M APU
    Motherboard
    Lenovo
    Memory
    8 GB
    Graphics card(s)
    Radeon HD (Embedded)
    Sound Card
    Conextant 20671 SmartAudio HD
    Monitor(s) Displays
    Lenovo 15" Matte
    Screen Resolution
    1680 * 1050
    Hard Drives
    INTEL Cherryvill 520 Series SSDSC2CW180A 180 GB SSD
    PSU
    Lenovo
    Case
    Lenovo
    Cooling
    Lenovo
    Mouse
    Logitech MX Master (shared) | Synaptics TouchPad
    Keyboard
    Lenovo
    Internet Speed
    AT&T LightSpeed Gigabit Duplex
Hello Johngalt,

Yes i have a 3 junction system files in the folder \Documents. My Music, My Pictures and My Video.
If copy manually folder \Documents to another directory exemple C:\BackupDocuments its the same problem... Permission Denied.

UAC is disabled and i am Administrator this computer.

This script run without erros in Windows XP. Copy all subfolders, files and shortcuts but windows vista x86 not run :(

Any solution?

Thanks
 

My Computer

System One

  • Memory
    4Gb
Those three junctions are always going to fail to copy - you'll have to include exclusions for that - and UAC is not the problem, stop disabling it.
 

My Computers

System One System Two

  • Operating System
    Windows 10 Pro X64 Insider Preview (Skip Ahead) latest build
    Manufacturer/Model
    The Beast Model V (homebrew)
    CPU
    Intel Core i7 965 EE @ 3.6 GHz
    Motherboard
    eVGA X58 Classified 3 (141-GT-E770-A1)
    Memory
    3 * Mushkin 998981 Redline Enhanced triple channel DDR3 4 GB CL7 DDR3 1600 MHz (PC3-12800)
    Graphics Card(s)
    eVGA GeForce GTX 970 SSC ACX 2.0 (04G-P4-3979-KB)
    Sound Card
    Realtek HD Audio (onboard)
    Monitor(s) Displays
    2 * Lenovo LT2323pwA Widescreeen
    Screen Resolution
    2 * 1920 x 1080
    Hard Drives
    SanDisk Ultra SDSSDHII-960G-G25 960 GB SATA III SSD (System)
    Crucial MX100 CT256MX100SSD1 256GB SATA III SSD (User Tree)
    2 * Seagate Barracuda 7200.12 ST31000528AS 1TB 7200 RPM SATA II Mech. HD
    Seagate ST1500DL001-9VT15L Barracuda 7200.12 1.5 TB S
    PSU
    Thermaltake Black Widow TX TR2 850W 80+ Bronze Semi-Mod ATX
    Case
    ThermalTake Level 10 GT (Black)
    Cooling
    Corsair H100 (CPU, dual 140 mm fans on radiator) + Air (2 *
    Keyboard
    Logitech G15 (gen 2)
    Mouse
    Logitech MX Master (shared)
    Internet Speed
    AT&T Lightspeed Gigabit duplex
  • Operating System
    Sabayon Linux (current, weekly updates, 5.1.x kernel)
    Manufacturer/Model
    Lenovo ThinkPad E545
    CPU
    AMD A6-5350M APU
    Motherboard
    Lenovo
    Memory
    8 GB
    Graphics card(s)
    Radeon HD (Embedded)
    Sound Card
    Conextant 20671 SmartAudio HD
    Monitor(s) Displays
    Lenovo 15" Matte
    Screen Resolution
    1680 * 1050
    Hard Drives
    INTEL Cherryvill 520 Series SSDSC2CW180A 180 GB SSD
    PSU
    Lenovo
    Case
    Lenovo
    Cooling
    Lenovo
    Mouse
    Logitech MX Master (shared) | Synaptics TouchPad
    Keyboard
    Lenovo
    Internet Speed
    AT&T LightSpeed Gigabit Duplex
Ok, how i have to include exclusions (Junctions My Video, My Pictures and My Music) in my code vbscript?
Cant i help me?
Can you write this code for me?

Thanks

'**** DOCUMENTS ****
If filesys.FolderExists ("C:\Users\" & StrUsername & "\Documents") Then
filesys.CreateFolder ("C:\Dados\" & StrUsername & ".$$$" & "\Documents")
filesys.CopyFolder "C:\Users\" & StrUsername & "\Documents", "C:\Dados\" & StrUsername & ".$$$" & "\Documents", OverwriteExisting

Best Regards
 

My Computer

System One

  • Memory
    4Gb
I can't help you there, but perhaps something like an OnError Resume in each of those may help....
 

My Computers

System One System Two

  • Operating System
    Windows 10 Pro X64 Insider Preview (Skip Ahead) latest build
    Manufacturer/Model
    The Beast Model V (homebrew)
    CPU
    Intel Core i7 965 EE @ 3.6 GHz
    Motherboard
    eVGA X58 Classified 3 (141-GT-E770-A1)
    Memory
    3 * Mushkin 998981 Redline Enhanced triple channel DDR3 4 GB CL7 DDR3 1600 MHz (PC3-12800)
    Graphics Card(s)
    eVGA GeForce GTX 970 SSC ACX 2.0 (04G-P4-3979-KB)
    Sound Card
    Realtek HD Audio (onboard)
    Monitor(s) Displays
    2 * Lenovo LT2323pwA Widescreeen
    Screen Resolution
    2 * 1920 x 1080
    Hard Drives
    SanDisk Ultra SDSSDHII-960G-G25 960 GB SATA III SSD (System)
    Crucial MX100 CT256MX100SSD1 256GB SATA III SSD (User Tree)
    2 * Seagate Barracuda 7200.12 ST31000528AS 1TB 7200 RPM SATA II Mech. HD
    Seagate ST1500DL001-9VT15L Barracuda 7200.12 1.5 TB S
    PSU
    Thermaltake Black Widow TX TR2 850W 80+ Bronze Semi-Mod ATX
    Case
    ThermalTake Level 10 GT (Black)
    Cooling
    Corsair H100 (CPU, dual 140 mm fans on radiator) + Air (2 *
    Keyboard
    Logitech G15 (gen 2)
    Mouse
    Logitech MX Master (shared)
    Internet Speed
    AT&T Lightspeed Gigabit duplex
  • Operating System
    Sabayon Linux (current, weekly updates, 5.1.x kernel)
    Manufacturer/Model
    Lenovo ThinkPad E545
    CPU
    AMD A6-5350M APU
    Motherboard
    Lenovo
    Memory
    8 GB
    Graphics card(s)
    Radeon HD (Embedded)
    Sound Card
    Conextant 20671 SmartAudio HD
    Monitor(s) Displays
    Lenovo 15" Matte
    Screen Resolution
    1680 * 1050
    Hard Drives
    INTEL Cherryvill 520 Series SSDSC2CW180A 180 GB SSD
    PSU
    Lenovo
    Case
    Lenovo
    Cooling
    Lenovo
    Mouse
    Logitech MX Master (shared) | Synaptics TouchPad
    Keyboard
    Lenovo
    Internet Speed
    AT&T LightSpeed Gigabit Duplex
Back
Top