wasserfa89
Technical User
hi all
I found the Script below to recreate damaged Outlook Profiles
So far so good, the script works fine, but after creating the blank profile it dosent find the file in c:\temp\profile.prf
-----------------------------------------------------------------
Option Explicit
'-------------------------------------------------------------------------
' MAPIAutocpnfig.vbs
'
' Beschreibung
' Das Programm sucht den aktuellen User im AD und liest den Homeserver und Alias aus
' Dann erstellt es eine PRF-Datei, später direkt das MAPI-Profil
'
' Achtung: Die PRF-Datei ist hier komplett im Script hinterlegt. Das erspart mir die Suche und das öffnen einer weiteren Datein
' Das VBscript benötigt damit nur noch Outlook 200x oder PROFGEN zum Funktionieren
' eine bestehende PRF-Datei wird überschrieben !!
'
' Das Skript wird mit den Berechtigungen des angemeldeten Benutzers
' ausgeführt. Die entsprechenden Berechtigungen sind sicher zu stellen
'
'
'-------------------------------------------------------------------------
Const EVENTLOG_SUCCESS = 0
Const EVENTLOG_ERROR = 1
Const EVENTLOG_WARNING = 2
Const EVENTLOG_INFORMATION = 4
Const EVENTLOG_AUDIT_SUCESS = 8
Const EVENTLOG_AUDIT_FAILURE = 10
Const Filename = "c:\temp\profile.prf"
Const OUTLOOKPATH = """\Microsoft Office\OFFICE11"""
Const ForWriting = 2
Dim wshShell, wshNet, objUser, objSysInfo, objTextFile, objFSO
Dim strResult, strHomeServer, strHomeServerDN, strUseralias
Dim objShell, objExecObject
Dim arrDN, WshSysEnv, oReg, PrgFiles
Dim outlook
outlook="outlook.exe"
Set wshShell = CreateObject("wscript.shell")
wshShell.logevent EVENTLOG_INFORMATION,"MAPIAutoConfig gestartet"
strResult = "MAPIAutoConfig gestartet"
Debugoutput "MAPIAutoConfig gestartet"
Set wshNet = CreateObject ("wscript.network")
strResult = strResult & VbCrLf & "Computer:" & wshNet.computername
Debugoutput "Computer:" & wshNet.computername
Set objSysInfo= CreateObject ("ADSystemInfo")
strResult = strResult & VbCrLf & "AD Username:" & objSysInfo.Username
Debugoutput "AD Username:" & objSysInfo.Username
Set objUser = GetObject("LDAP://" & objSysInfo.Username)
Set objUser = GetObject("LDAP://" & objSysInfo.Username)
'strUseralias = objUser.alias
' Alternativ: strUseralias = objUser.mail
strResult = strResult & VbCrLf & "strUseralias:" & strUseralias
Debugoutput "strUseralias:" & strUseralias
'Get System Architecture
Set WshSysEnv = wshShell.Environment("SYSTEM")
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv")
If WshSysEnv("PROCESSOR_ARCHITECTURE") = "AMD64" Then
PrgFiles = "Program Files(x86)"
Else
PrgFiles = "Program Files"
End If
strHomeServerDN = objUser.get("msExchHomeServerName")
If strHomeServerDN = "" Then
strResult = strResult & VbCrLf & "strHomeServerDN: leer. User hat kein Postfach"
Debugoutput "strHomeServerDN: leer. User hat kein Postfach"
wshShell.logevent EVENTLOG_WARNING,"strHomeServerDN: leer. User hat kein Postfach"
Else
strResult = strResult & VbCrLf & "strHomeServerDN:" & strHomeServerDN
Debugoutput "strHomeServerDN:" & strHomeServerDN
arrDN = Split(strHomeServerDN,"cn=")
strHomeServer = arrDN(UBound(arrDN)) 'Get last record
strResult = strResult & VbCrLf & "strHomeServer:" & strHomeServer
Debugoutput "HomeServer:" & strHomeServer
Debugoutput "CreateProfile: "& VbCrLf & _
" Username = " & strUseralias & VbCrLf & _
" Servername= " & strHomeServer
Debugoutput "Bitte warten Profil wird neu konfiguriert"
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.CreateTextFile(Filename,ForWriting)
'~ Set objTextFile = objFSO.OpenTextFile("C:\temp\profile.prf", ForWriting)
objTextFile.WriteLine("[General]")
objTextFile.WriteLine("Custom=1")
objTextFile.WriteLine("ProfileName=Outlook")
objTextFile.WriteLine("DefaultProfile=Yes")
objTextFile.WriteLine("OverwriteProfile=yes")
'~ objTextFile.WriteLine("ModifyDefaultProfileIfPresent=TRUE")
objTextFile.WriteLine("DefaultStore=Service2")
objTextFile.WriteLine("BackupProfile=No ")
objTextFile.WriteLine("")
objTextFile.WriteLine("; **************************************************************")
objTextFile.WriteLine("; Section 2 - Services in Profile")
objTextFile.WriteLine("; **************************************************************")
objTextFile.WriteLine("[Service List]")
objTextFile.WriteLine("Service1=Microsoft Outlook Client")
objTextFile.WriteLine("Service2=Microsoft Exchange Server")
objTextFile.WriteLine("Service3=Outlook Address Book")
objTextFile.WriteLine("")
objTextFile.WriteLine(";***************************************************************")
objTextFile.WriteLine("; Section 4 - Default values for each service.")
objTextFile.WriteLine(";***************************************************************")
objTextFile.WriteLine("[Service1]")
objTextFile.WriteLine("CachedExchangeMode=0x00000002")
objTextFile.WriteLine("CachedExchangeSlowDetect=FALSE")
objTextFile.WriteLine("AutoArchiveFileName=%USERPROFILE%\My Documents\outlook\archive.pst")
objTextFile.WriteLine("ArchiveSettings=0x01c501efa21ae85a")
objTextFile.WriteLine("")
objTextFile.WriteLine("[Service2]")
objTextFile.WriteLine("OverwriteExistingService=no")
objTextFile.WriteLine("UniqueService=Yes")
objTextFile.WriteLine("MailboxName="& strUseralias)
objTextFile.WriteLine("HomeServer="& strHomeServer)
objTextFile.WriteLine("AccountName=Microsoft Exchange Server")
objTextFile.WriteLine("CachedExchangeConfigFlags=0x00000500")
objTextFile.WriteLine("OfflineAddressBookPath=%USERPROFILE%\my documents\outlook\")
objTextFile.WriteLine("OfflineFolderPath=%USERPROFILE%\My Documents\outlook\outlook.ost")
objTextFile.WriteLine("ExchangeConfigFlags=0x00000004 ; for desktops")
objTextFile.WriteLine("")
objTextFile.WriteLine("[Service3]")
objTextFile.WriteLine("")
objTextFile.WriteLine(";***************************************************************")
objTextFile.WriteLine("; Section 6 - Mapping for profile properties")
objTextFile.WriteLine(";***************************************************************")
objTextFile.WriteLine("")
objTextFile.WriteLine("[Microsoft Exchange Server]")
objTextFile.WriteLine("ServiceName=MSEMS")
objTextFile.WriteLine("MDBGUID=5494A1C0297F101BA58708002B2A2517")
objTextFile.WriteLine("MailboxName=PT_STRING8,0x6607")
objTextFile.WriteLine("HomeServer=PT_STRING8,0x6608")
objTextFile.WriteLine("OfflineAddressBookPath=PT_STRING8,0x660E")
objTextFile.WriteLine("OfflineFolderPath=PT_STRING8,0x6610")
objTextFile.WriteLine("ExchangeConfigFlags=PT_LONG,0x6601")
objTextFile.WriteLine("")
objTextFile.WriteLine("[Exchange Global Section]")
objTextFile.WriteLine("SectionGUID=13dbb0c8aa05101a9bb000aa002fc45a")
objTextFile.WriteLine("MailboxName=PT_STRING8,0x6607")
objTextFile.WriteLine("HomeServer=PT_STRING8,0x6608")
objTextFile.WriteLine("RPCoverHTTPflags=PT_LONG,0x6623")
objTextFile.WriteLine("RPCProxyServer=PT_UNICODE,0x6622")
objTextFile.WriteLine("RPCProxyPrincipalName=PT_UNICODE,0x6625")
objTextFile.WriteLine("RPCProxyAuthScheme=PT_LONG,0x6627")
objTextFile.WriteLine("CachedExchangeConfigFlags=PT_LONG,0x6629")
objTextFile.WriteLine("")
objTextFile.WriteLine("[Outlook Address Book]")
objTextFile.WriteLine("ServiceName=CONTAB")
objTextFile.WriteLine("")
objTextFile.WriteLine("[Microsoft Outlook Client]")
objTextFile.WriteLine("SectionGUID=0a0d020000000000c000000000000046")
objTextFile.WriteLine("FormDirectoryPage=PT_STRING8,0x0270")
objTextFile.WriteLine("WebServicesLocation=PT_STRING8,0x0271")
objTextFile.WriteLine("ComposeWithWebServices=PT_BOOLEAN,0x0272")
objTextFile.WriteLine("PromptWhenUsingWebServices=PT_BOOLEAN,0x0273")
objTextFile.WriteLine("OpenWithWebServices=PT_BOOLEAN,0x0274")
objTextFile.WriteLine("CachedExchangeMode=PT_LONG,0x041f")
objTextFile.WriteLine("CachedExchangeSlowDetect=PT_BOOLEAN,0x0420")
objTextFile.WriteLine("ArchiveSettings=0x0040,0x0032")
objTextFile.WriteLine("DoAutoArchive=PT_BOOLEAN,0x0320")
objTextFile.WriteLine("AutoArchiveFileName=PT_STRING8,0x0324")
objTextFile.WriteLine("FormDirectoryPage=PT_STRING8,0x0270")
objTextFile.WriteLine("EmptyWastebasket=PT_BOOLEAN,0x0115")
objTextFile.WriteLine("SelectEntireWord=PT_BOOLEAN,0x0118")
objTextFile.WriteLine("AfterMoveMessage=PT_LONG,0x013B")
objTextFile.WriteLine("CloseOriginalMessage=PT_BOOLEAN,0x0132")
objTextFile.WriteLine("GenReadReceipt=PT_BOOLEAN,0x0141")
objTextFile.WriteLine("GenDeliveryReceipt=PT_BOOLEAN,0x014C")
objTextFile.WriteLine("DefaultSensitivity=PT_LONG,0x014F")
objTextFile.WriteLine("DefaultPriority=PT_LONG,0x0140")
objTextFile.WriteLine("SaveSentMail=PT_BOOLEAN,0x0142")
objTextFile.Close
Debugoutput "Profil wurde neu erstellt"
'If wshShell.RegRead("HKCU\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles") = "" Then
'wshShell.logevent EVENTLOG_WARNING,"Kein MAPI-Profil vorhanden"
'Else
'wshShell.logevent EVENTLOG_WARNING,"MAPI-Profil vorhanden"
'End If
Set objShell = CreateObject("WScript.Shell")
'outlook /importprf prffilename
Set objExecObject = objShell.Exec(outlook & "/importprf" & filename )
End If
wshShell.logevent EVENTLOG_INFORMATION,"MAPIAutoConfig beendet" & VbCrLf & strResult
Sub Debugoutput(strmessage)
WScript.echo "Debug:" & strmessage
End Sub
------------------------------------------------------------------
any ideas?
thanks
I found the Script below to recreate damaged Outlook Profiles
So far so good, the script works fine, but after creating the blank profile it dosent find the file in c:\temp\profile.prf
-----------------------------------------------------------------
Option Explicit
'-------------------------------------------------------------------------
' MAPIAutocpnfig.vbs
'
' Beschreibung
' Das Programm sucht den aktuellen User im AD und liest den Homeserver und Alias aus
' Dann erstellt es eine PRF-Datei, später direkt das MAPI-Profil
'
' Achtung: Die PRF-Datei ist hier komplett im Script hinterlegt. Das erspart mir die Suche und das öffnen einer weiteren Datein
' Das VBscript benötigt damit nur noch Outlook 200x oder PROFGEN zum Funktionieren
' eine bestehende PRF-Datei wird überschrieben !!
'
' Das Skript wird mit den Berechtigungen des angemeldeten Benutzers
' ausgeführt. Die entsprechenden Berechtigungen sind sicher zu stellen
'
'
'-------------------------------------------------------------------------
Const EVENTLOG_SUCCESS = 0
Const EVENTLOG_ERROR = 1
Const EVENTLOG_WARNING = 2
Const EVENTLOG_INFORMATION = 4
Const EVENTLOG_AUDIT_SUCESS = 8
Const EVENTLOG_AUDIT_FAILURE = 10
Const Filename = "c:\temp\profile.prf"
Const OUTLOOKPATH = """\Microsoft Office\OFFICE11"""
Const ForWriting = 2
Dim wshShell, wshNet, objUser, objSysInfo, objTextFile, objFSO
Dim strResult, strHomeServer, strHomeServerDN, strUseralias
Dim objShell, objExecObject
Dim arrDN, WshSysEnv, oReg, PrgFiles
Dim outlook
outlook="outlook.exe"
Set wshShell = CreateObject("wscript.shell")
wshShell.logevent EVENTLOG_INFORMATION,"MAPIAutoConfig gestartet"
strResult = "MAPIAutoConfig gestartet"
Debugoutput "MAPIAutoConfig gestartet"
Set wshNet = CreateObject ("wscript.network")
strResult = strResult & VbCrLf & "Computer:" & wshNet.computername
Debugoutput "Computer:" & wshNet.computername
Set objSysInfo= CreateObject ("ADSystemInfo")
strResult = strResult & VbCrLf & "AD Username:" & objSysInfo.Username
Debugoutput "AD Username:" & objSysInfo.Username
Set objUser = GetObject("LDAP://" & objSysInfo.Username)
Set objUser = GetObject("LDAP://" & objSysInfo.Username)
'strUseralias = objUser.alias
' Alternativ: strUseralias = objUser.mail
strResult = strResult & VbCrLf & "strUseralias:" & strUseralias
Debugoutput "strUseralias:" & strUseralias
'Get System Architecture
Set WshSysEnv = wshShell.Environment("SYSTEM")
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv")
If WshSysEnv("PROCESSOR_ARCHITECTURE") = "AMD64" Then
PrgFiles = "Program Files(x86)"
Else
PrgFiles = "Program Files"
End If
strHomeServerDN = objUser.get("msExchHomeServerName")
If strHomeServerDN = "" Then
strResult = strResult & VbCrLf & "strHomeServerDN: leer. User hat kein Postfach"
Debugoutput "strHomeServerDN: leer. User hat kein Postfach"
wshShell.logevent EVENTLOG_WARNING,"strHomeServerDN: leer. User hat kein Postfach"
Else
strResult = strResult & VbCrLf & "strHomeServerDN:" & strHomeServerDN
Debugoutput "strHomeServerDN:" & strHomeServerDN
arrDN = Split(strHomeServerDN,"cn=")
strHomeServer = arrDN(UBound(arrDN)) 'Get last record
strResult = strResult & VbCrLf & "strHomeServer:" & strHomeServer
Debugoutput "HomeServer:" & strHomeServer
Debugoutput "CreateProfile: "& VbCrLf & _
" Username = " & strUseralias & VbCrLf & _
" Servername= " & strHomeServer
Debugoutput "Bitte warten Profil wird neu konfiguriert"
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.CreateTextFile(Filename,ForWriting)
'~ Set objTextFile = objFSO.OpenTextFile("C:\temp\profile.prf", ForWriting)
objTextFile.WriteLine("[General]")
objTextFile.WriteLine("Custom=1")
objTextFile.WriteLine("ProfileName=Outlook")
objTextFile.WriteLine("DefaultProfile=Yes")
objTextFile.WriteLine("OverwriteProfile=yes")
'~ objTextFile.WriteLine("ModifyDefaultProfileIfPresent=TRUE")
objTextFile.WriteLine("DefaultStore=Service2")
objTextFile.WriteLine("BackupProfile=No ")
objTextFile.WriteLine("")
objTextFile.WriteLine("; **************************************************************")
objTextFile.WriteLine("; Section 2 - Services in Profile")
objTextFile.WriteLine("; **************************************************************")
objTextFile.WriteLine("[Service List]")
objTextFile.WriteLine("Service1=Microsoft Outlook Client")
objTextFile.WriteLine("Service2=Microsoft Exchange Server")
objTextFile.WriteLine("Service3=Outlook Address Book")
objTextFile.WriteLine("")
objTextFile.WriteLine(";***************************************************************")
objTextFile.WriteLine("; Section 4 - Default values for each service.")
objTextFile.WriteLine(";***************************************************************")
objTextFile.WriteLine("[Service1]")
objTextFile.WriteLine("CachedExchangeMode=0x00000002")
objTextFile.WriteLine("CachedExchangeSlowDetect=FALSE")
objTextFile.WriteLine("AutoArchiveFileName=%USERPROFILE%\My Documents\outlook\archive.pst")
objTextFile.WriteLine("ArchiveSettings=0x01c501efa21ae85a")
objTextFile.WriteLine("")
objTextFile.WriteLine("[Service2]")
objTextFile.WriteLine("OverwriteExistingService=no")
objTextFile.WriteLine("UniqueService=Yes")
objTextFile.WriteLine("MailboxName="& strUseralias)
objTextFile.WriteLine("HomeServer="& strHomeServer)
objTextFile.WriteLine("AccountName=Microsoft Exchange Server")
objTextFile.WriteLine("CachedExchangeConfigFlags=0x00000500")
objTextFile.WriteLine("OfflineAddressBookPath=%USERPROFILE%\my documents\outlook\")
objTextFile.WriteLine("OfflineFolderPath=%USERPROFILE%\My Documents\outlook\outlook.ost")
objTextFile.WriteLine("ExchangeConfigFlags=0x00000004 ; for desktops")
objTextFile.WriteLine("")
objTextFile.WriteLine("[Service3]")
objTextFile.WriteLine("")
objTextFile.WriteLine(";***************************************************************")
objTextFile.WriteLine("; Section 6 - Mapping for profile properties")
objTextFile.WriteLine(";***************************************************************")
objTextFile.WriteLine("")
objTextFile.WriteLine("[Microsoft Exchange Server]")
objTextFile.WriteLine("ServiceName=MSEMS")
objTextFile.WriteLine("MDBGUID=5494A1C0297F101BA58708002B2A2517")
objTextFile.WriteLine("MailboxName=PT_STRING8,0x6607")
objTextFile.WriteLine("HomeServer=PT_STRING8,0x6608")
objTextFile.WriteLine("OfflineAddressBookPath=PT_STRING8,0x660E")
objTextFile.WriteLine("OfflineFolderPath=PT_STRING8,0x6610")
objTextFile.WriteLine("ExchangeConfigFlags=PT_LONG,0x6601")
objTextFile.WriteLine("")
objTextFile.WriteLine("[Exchange Global Section]")
objTextFile.WriteLine("SectionGUID=13dbb0c8aa05101a9bb000aa002fc45a")
objTextFile.WriteLine("MailboxName=PT_STRING8,0x6607")
objTextFile.WriteLine("HomeServer=PT_STRING8,0x6608")
objTextFile.WriteLine("RPCoverHTTPflags=PT_LONG,0x6623")
objTextFile.WriteLine("RPCProxyServer=PT_UNICODE,0x6622")
objTextFile.WriteLine("RPCProxyPrincipalName=PT_UNICODE,0x6625")
objTextFile.WriteLine("RPCProxyAuthScheme=PT_LONG,0x6627")
objTextFile.WriteLine("CachedExchangeConfigFlags=PT_LONG,0x6629")
objTextFile.WriteLine("")
objTextFile.WriteLine("[Outlook Address Book]")
objTextFile.WriteLine("ServiceName=CONTAB")
objTextFile.WriteLine("")
objTextFile.WriteLine("[Microsoft Outlook Client]")
objTextFile.WriteLine("SectionGUID=0a0d020000000000c000000000000046")
objTextFile.WriteLine("FormDirectoryPage=PT_STRING8,0x0270")
objTextFile.WriteLine("WebServicesLocation=PT_STRING8,0x0271")
objTextFile.WriteLine("ComposeWithWebServices=PT_BOOLEAN,0x0272")
objTextFile.WriteLine("PromptWhenUsingWebServices=PT_BOOLEAN,0x0273")
objTextFile.WriteLine("OpenWithWebServices=PT_BOOLEAN,0x0274")
objTextFile.WriteLine("CachedExchangeMode=PT_LONG,0x041f")
objTextFile.WriteLine("CachedExchangeSlowDetect=PT_BOOLEAN,0x0420")
objTextFile.WriteLine("ArchiveSettings=0x0040,0x0032")
objTextFile.WriteLine("DoAutoArchive=PT_BOOLEAN,0x0320")
objTextFile.WriteLine("AutoArchiveFileName=PT_STRING8,0x0324")
objTextFile.WriteLine("FormDirectoryPage=PT_STRING8,0x0270")
objTextFile.WriteLine("EmptyWastebasket=PT_BOOLEAN,0x0115")
objTextFile.WriteLine("SelectEntireWord=PT_BOOLEAN,0x0118")
objTextFile.WriteLine("AfterMoveMessage=PT_LONG,0x013B")
objTextFile.WriteLine("CloseOriginalMessage=PT_BOOLEAN,0x0132")
objTextFile.WriteLine("GenReadReceipt=PT_BOOLEAN,0x0141")
objTextFile.WriteLine("GenDeliveryReceipt=PT_BOOLEAN,0x014C")
objTextFile.WriteLine("DefaultSensitivity=PT_LONG,0x014F")
objTextFile.WriteLine("DefaultPriority=PT_LONG,0x0140")
objTextFile.WriteLine("SaveSentMail=PT_BOOLEAN,0x0142")
objTextFile.Close
Debugoutput "Profil wurde neu erstellt"
'If wshShell.RegRead("HKCU\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles") = "" Then
'wshShell.logevent EVENTLOG_WARNING,"Kein MAPI-Profil vorhanden"
'Else
'wshShell.logevent EVENTLOG_WARNING,"MAPI-Profil vorhanden"
'End If
Set objShell = CreateObject("WScript.Shell")
'outlook /importprf prffilename
Set objExecObject = objShell.Exec(outlook & "/importprf" & filename )
End If
wshShell.logevent EVENTLOG_INFORMATION,"MAPIAutoConfig beendet" & VbCrLf & strResult
Sub Debugoutput(strmessage)
WScript.echo "Debug:" & strmessage
End Sub
------------------------------------------------------------------
any ideas?
thanks