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
| 'Option Explicit
'On Error Resume Next
Dim objShell,objFSO,objTextFile,objOutlook,objMAPI,WshNetwork,Varnow,Current,Vardate
Dim PSTfolder,userPath,pstPath,strSubString,UserUpn,strComputer,NetPath
Const OverwriteExisting = True
Varnow = now
Current = TimeHHMMSS()
Vardate = Day(varnow) & "-" & Month(varnow) & "-" & Year(varnow) & "_at_" & Current
Set objShell = CreateObject("wscript.shell")
Set WshNetwork = WScript.CreateObject("WScript.Network")
UserPath = objShell.ExpandEnvironmentStrings("%userprofile%")
UserUpn = WshNetwork.UserName
strComputer = WshNetwork.ComputerName
NetPath = "\\sa000e\LogsArch$\"
Set objFSO = CreateObject("scripting.filesystemobject")
Set objTextFile = objFSO.CreateTextFile _
(userPath & "\" & Vardate & "_pst.log")
Set objOutlook = createObject("Outlook.Application")
set objMAPI = objOutlook.GetNamespace("MAPI")
for each PSTFolder In objMAPI.Folders
pstPath = GetPath(PSTFolder.StoreID)
if pstPath <> "" Then
objTextFile.WriteLine(PSTFolder.name & " : " & pstPath)
end if
Next
On Error goto 0
' *********************L'ERREUR EST ICI*********************************
WScript.Echo userPath & "\" & objFSO.GetFileName(objTextFile) & NetPath & strComputer & "_" & userUpn & "_" & Now() & "_pst.log"
function GetPath(input)
for i = 1 To Len(input) Step 2
strSubString = Mid(input,i,2)
if Not strSubString = "00" Then
strPath = strPath & ChrW("&H" & strSubString)
end If
next
select Case True
case InStr(strPath,":\") > 0
GetPath = Mid(strPath,InStr(strPath,":\")-1)
case InStr(strPath,"\\") > 0
GetPath = Mid(strPath,InStr(strPath,"\\"))
end Select
end Function
Function TimeHHMMSS()
Dim retv, d
d = Now
retv = Right("00" & Hour(d), 2) & "-" & Right("00" & Minute(d), 2) & "-" & Right("00" & Second(d), 2)
TimeHHMMSS = retv
End Function |
Partager