bonjour j'ai fais un script pour une sauvegarde Outlook mais je n'arrive pas a garder les droits sur le fichier sauvegardé sauriez vous m'indiquer la marche à suivre ;merci
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98 'Set the amount of pst-files you want to copy. Start counting at 0! ReDim pst(0) 'Define the location of each pst-file to backup. Increase the counter! Set Shell = Wscript.CreateObject ("Wscript.Shell") Username = Shell.ExpandEnvironmentStrings ("%USERNAME%") Msgbox "Le nom de l'utilisateur est " & Username pst(0) = "D:\..\USERS\" & Username & "\Documents\Fichiers Outlook\archive.pst" 'Define your backup location BackupPath = "\\..F\install\archive_outlook\" & Username & "\" 'Keep old backups? TRUE/FALSE KeepHistory = FALSE 'Maximum time in milliseconds for Outlook to close on its own delay = 30000 'It is not recommended to set this below 8000 'Start Outlook again afterwards? TRUE/FALSE start = TRUE '---------------------------------------------------------------------------------------- ' **** POPUP AVERTISSEMENT ***** '---------------------------------------------------------------------------------------- MsgBox "Sauvegarde de vos mails en cours, Outlook sera ouvert automatiquement à la fin de la sauvegarde.Copie en cours de votre archive vers le NAS. Ne pas fermer cette fenetre. Patienter SVP..." '---------------------------------------------------------------------------------------- ' **** COPIE PST EN BACKUP SUR SERVEUR **** '---------------------------------------------------------------------------------------- 'Close Outlook Call CloseOutlook(delay) 'Outlook is closed, so we can start the backup Call BackupPST(pst, BackupPath, KeepHistory) 'Open Outlook again when desired. If start = TRUE Then Call OpenOutlook() End If Sub CloseOutlook(delay) strComputer = "." Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") 'If Outlook is running, let it quit on its own. For Each Process in objWMIService.InstancesOf("Win32_Process") If StrComp(Process.Name,"OUTLOOK.EXE",vbTextCompare) = 0 Then Set objOutlook = CreateObject("Outlook.Application") objOutlook.Quit WScript.Sleep delay Exit For End If Next 'Make sure Outlook is closed and otherwise force it. Set colProcessList = objWMIService.ExecQuery _ ("Select * from Win32_Process Where Name = 'Outlook.exe'") For Each objProcess in colProcessList objProcess.Terminate() Next Set objWMIService = Nothing Set objOutlook = Nothing set colProcessList = Nothing End Sub Sub BackupPST(pst, BackupPath, KeepHistory) Set fso = CreateObject("Scripting.FileSystemObject") If KeepHistory = True Then ArchiveFolder = Year(Now) & "-" & Month(Now) & "-" & Day(Now) BackupPath = BackupPath & ArchiveFolder & "\" End If If fso.FolderExists(BackupPath) = False Then fso.CreateFolder BackupPath End If For Each pstPath in pst If fso.FileExists(pstPath) Then fso.CopyFile pstPath, BackupPath, True End If Next Set fso = Nothing End Sub Sub OpenOutlook() Set objShell = CreateObject("WScript.Shell") objShell.Run "Outlook.exe" End Sub
Partager