I am working on a logon script (GPO) that checks for an Outlook Profile, if one exists/does not exist, it either creates a registry key or exits the instruction loop. Both cases create a log event with a descriptive text entry. If the script is executed standalone (just run from command line or from windows explorer) it works normally. If executed via a logon script (standard GPO) it works, but it creates like 10 duplicate entries in the event log. I have never seen this before and thought I would put out some feelers to see if anyone has and found the solution for it.
Code:
Const HKLM = &H80000002
Const HKCU = &H80000001
Const Event_Information = 4
strComputer = "."
Set objReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv")
Set objShell = wscript.CreateObject("wscript.Shell")
Set wshNetwork = CreateObject("wscript.Network")
strOfficeKey = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\"
strEntry1a = "DisplayName"
objReg.EnumKey HKLM, strOfficeKey, arrSubkeys
strProfilePath = "Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles"
'set variables to search the current user profile to see if a mail profile has been created
strProfileValueName = "DefaultProfile"
objReg.GetStringValue HKCU, strProfilePath, strProfileValueName, strValue
'set variables to remove the first-run value if there is no mail profile
strDeleteValuePath = "Software\Microsoft\Office\12.0\Outlook\Setup"
strDeleteValue = "First-Run"
strNewValueName = "ImportPRF"
strNewValue = "\\<sourcefilelocation>\Office2007Pro\outlook.prf"
'check uninstaller repository for the correct version of Office
For Each strSubkey In arrSubkeys
intRet1 = objReg.GetStringValue(HKLM, strOfficeKey & strSubkey, strEntry1a, strValue1)
If intRet1 <> 0 Then
objReg.GetStringValue HKLM, strOfficeKey & strSubkey, strEntry1b, strValue1
End If
'If Office 2007 is found, install the registry keys needed for Outlook profiles
If strValue1 <> "" and strValue1 = "Microsoft Office Professional Plus 2007" Then
'get the current logged on user
strUser = wshNetwork.Username
If isNull(strValue) Then
'import office prf routine here
objReg.DeleteValue HKCU, strDeleteValuePath, strDeleteValue
objReg.SetStringValue HKCU, strDeleteValuePath, strNewValueName, strNewValue
objShell.LogEvent Event_Information, "Outlook configuration file imported for user: " & strUser
Else
objShell.LogEvent Event_Information, "Outlook profile already exists for user: " & strUser & ". Office will install normally."
End If
Else
'make the registry key manually before Office 2007 is installed
objReg.CreateKey HKCU, strDeleteValuePath
objReg.SetStringValue HKCU, strDeleteValuePath, strNewValueName, strNewValue
objShell.LogEvent Event_Information, "Office 2007 not installed, outlook configuration file path entered into registry"
End If
Next