1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
| Set objShell = CreateObject("Wscript.Shell")
objSource = InputBox("Enter Source")
objDestination = InputBox("Enter Destination")
objCommand = "RoboCopy.Exe " & Chr(34) & objSource & Chr(34) & " " & Chr(34) & objDestination & Chr(34) & " /SEC /E /r:1 /w:2"
objShell.Run(objCommand)
Set objWMIServiceSource = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & objSource & "\root\cimv2" )
Set ListeDesPartagesSource = objWMIServiceSource.ExecQuery("Select * from Win32_Share" )
Set objWMIServiceDestination = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & objDestination & "\root\cimv2" )
Set ListeDesPartagesDestination = objWMIServiceDestination.ExecQuery _
("Select * from Win32_Share" )
Set NouveauPartage = objWMIServiceDestination.Get("Win32_Share" )
For each PartageSource in ListeDesPartagesSource
PartageExiste = False
For each PartageDestination in ListeDesPartagesDestination
If PartageDestination.Name = PartageSource.Name Then
PartageExiste = True
PartageDestination.Path = PartageSource.Path
PartageDestination.Type = PartageSource.Type
PartageDestination.MaximumAllowed = PartageSource.MaximumAllowed
PartageDestination.Caption = PartageSource.Caption
End If
Next
If Not PartageExiste Then
CodeRetour = NouveauPartage.Create(PartageSource.Path, PartageSource.Name, _
PartageSource.Type, PartageSource.MaximumAllowed, _
PartageSource.Caption)
End If
Next |
Partager