<?xml version="1.0" encoding="UTF-8"?>
<SapSetup Context="Variables" Version="6">
	<Variable Name="MSO2010PIAExists" Persistent="FALSE">
		<Value>UNDEFINED</Value>
		<Value Script="TRUE"><![CDATA[
If %MSO2010Exists% = TRUE Or %MSProject2010Exists% = TRUE Then
                    NwEngine.Context.Log.Write "Script MSOfficePIA: Checking if the Microsoft Office 2010 PIA is already installed in version '14.0.4763.1024'."
                    'NWEngine.Variables.Persistent( "MSO2010PIAExists" ) = vbFalse
                    strUninstallKey = "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{90140000-1105-0000-0000-0000000FF1CE}"
                    If NwEngine.Shell.RegKeyExist( strUninstallKey ) Then
                        NWEngine.Variables.AppendDefaultValue "MSO2010PIAExists", "TRUE"
                        NwEngine.Context.Log.Write "Script MSOfficePIA: Microsoft Office 2010 PIA is already installed in this version '14.0.4763.1024'."
                    Else
                        NwEngine.Context.Log.Write "Script MSOfficePIA: Microsoft Office 2010 PIA is not installed"
                        NWEngine.Variables.AppendDefaultValue "MSO2010PIAExists", "FALSE"
                    End If
                End If
		]]></Value>
	</Variable>
	<Variable Name="MSO2007PIAExists" Persistent="FALSE">
		<Value>UNDEFINED</Value>
		<Value Script="TRUE"><![CDATA[
If %MSO2007Exists% = TRUE Or %MSProject2007Exists% = TRUE Then
                    NwEngine.Context.Log.Write "Script MSOfficePIA: Checking if the Microsoft Office 2007 PIA is already installed in version '12.0.4518.1014'."
                    'NWEngine.Variables.Persistent( "MSO2007PIAExists" ) = vbFalse
                    strUninstallKey = "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{50120000-1105-0000-0000-0000000FF1CE}"
                    If NwEngine.Shell.RegKeyExist( strUninstallKey ) Then
                        NWEngine.Variables.AppendDefaultValue "MSO2007PIAExists", "TRUE"
                        NwEngine.Context.Log.Write "Script MSOfficePIA: Microsoft Office 2007 PIA is already installed in this version '12.0.4518.1014'."
                    Else
                        NwEngine.Context.Log.Write "Script MSOfficePIA: Microsoft Office 2007 PIA is not installed"
                        NWEngine.Variables.AppendDefaultValue "MSO2007PIAExists", "FALSE"
                    End If
                End If
		]]></Value>
	</Variable>
	<Variable Name="MSO2003PIAExists" Persistent="FALSE">
		<Value>UNDEFINED</Value>
		<Value Script="TRUE"><![CDATA[
If %MSO2003Exists% = TRUE Or %MSProject2003Exists% = TRUE Then
                    NwEngine.Context.Log.Write "Script MSOfficePIA: Checking if the Microsoft Office 2003 PIA is already installed in version '11.0.6553.0'."
                    'NWEngine.Variables.Persistent( "MSO2003PIAExists" ) = vbFalse
                    strUninstallKey = "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{91490409-6000-11D3-8CFE-0150048383C9}"
                    If NwEngine.Shell.RegKeyExist( strUninstallKey ) Then
                        NWEngine.Variables.AppendDefaultValue "MSO2003PIAExists", "TRUE"
                        NwEngine.Context.Log.Write "Script MSOfficePIA: Microsoft Office 2003 PIA is already installed in this version '11.0.6553.0'."
                    Else
                        NWEngine.Variables.AppendDefaultValue "MSO2003PIAExists", "FALSE"
                        NwEngine.Context.Log.Write "Script MSOfficePIA: Microsoft Office 2003 PIA is not installed"
                    End If
                End If
		]]></Value>
	</Variable>
	<Variable Name="OTKLOADR_Exists" Persistent="FALSE">
		<Value>UNDEFINED</Value>
		<Value Script="TRUE"><![CDATA[
If %MSO2003Exists% = TRUE Or %MSProject2003Exists% = TRUE Then
                    'Setting variables for SapSetup
                    NwEngine.Context.Log.Write "Script MSOfficePIA: Reading Fileversion of OTKLOADR.DLL "
        
                    'Get Office2003 Install Dir
                    If NwEngine.Shell.RegKeyExist("HKLM\SOFTWARE\Microsoft\Office\11.0\Common\InstallRoot") Then
                        szMsOfficeDir = NwEngine.Shell.GetRegValue ("HKLM\SOFTWARE\Microsoft\Office\11.0\Common\InstallRoot\Path")
                        NwEngine.Context.Log.Write "Script-Action: Office 2003 found in " & szMsOfficeDir
                                                OtkloadrDLL = szMsOfficeDir & "ADDINS\Otkloadr.dll"
                                                If NwEngine.Shell.FileExist(OtkloadrDLL) Then
                            Set objFSO = CreateObject("Scripting.FileSystemObject")
                            fileVersion = objFSO.GetFileVersion(OtkloadrDLL)
                            neededVersion = "7.10.5077.0"
                            NwEngine.Context.Log.Write "Script-Action: Found OTKLOADR.DLL in Version " & fileVersion
                            If fileVersion >= neededVersion Then
                                NWEngine.Context.Log.Write "Script-Action: OTKLOADR.DLL versionnumber >= " & neededVersion
                                NWEngine.Variables.AppendDefaultValue "OTKLOADR_Exists", "TRUE"
                            Else
                                NWEngine.Context.Log.Write "Script-Action: RESULT: OTKLOADR.DLL versionnumber < " & neededVersion
                                NWEngine.Variables.AppendDefaultValue "OTKLOADR_Exists", "FALSE"
                            End If
                        Else
                            NWEngine.Context.Log.Write "Script-Action: RESULT: File " & OtkloadrDLL & " does not exist!"
                            NWEngine.Variables.AppendDefaultValue "OTKLOADR_Exists", "FALSE"
                        End If
                    End If
                Else
                    NwEngine.Context.Log.Write "Script MSOfficePIA: Office 2003 not installed, OTKLOADR-Patch not needed"
                End If
		]]></Value>
	</Variable>
	<Variable Name="Office2007_2010_VSTO_Installed">
		<Value>UNDEFINED</Value>
		<Value Script="TRUE"><![CDATA[
If %MSO2010Exists% = TRUE OR %MSO2007Exists% = TRUE Then
                    NwEngine.Context.Log.Write "Checking if VSTO 4.0 for Office 2007 or 2010 is installed"
                    If %WOW64MODE% = TRUE Then
                        NwEngine.Shell.Use64BitHive = true
                        szRegKey64 = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Microsoft Visual Studio 2010 Tools for Office Runtime (x64)"
                        If NwEngine.Shell.RegKeyExist(szRegKey64) Then
                            If NwEngine.Shell.RegValueExist(szRegKey64 & "\DisplayVersion") Then
                                szRegValue64 = NwEngine.Shell.GetRegValue(szRegKey64 & "\DisplayVersion")
                                NwEngine.Context.Log.Write "Found VSTO 4.0 in version '" & szRegValue64 & "'."
                                NwEngine.Variables.AppendDefaultValue "Office2007_2010_VSTO_Installed", "TRUE"
                            Else
                                NwEngine.Context.Log.Write "RegKey '" & szRegKey64 & "' found, but Value 'DisplayVersion' is not present! -> VSTO not installed correctly"
                            End If
                        Else
                            NwEngine.Context.Log.Write "VSTO 4.0 not found!"
                        End If
                        NwEngine.Shell.Use64BitHive = false
                    Else
                        szRegKey32 = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Microsoft Visual Studio 2010 Tools for Office Runtime (x86)"
                        If NwEngine.Shell.RegKeyExist(szRegKey32) Then
                            If NwEngine.Shell.RegValueExist(szRegKey32 & "\DisplayVersion") Then
                                szRegValue32 = NwEngine.Shell.GetRegValue(szRegKey32 & "\DisplayVersion")
                                NwEngine.Context.Log.Write "Found VSTO 4.0 in version '" & szRegValue32 & "'."
                                NwEngine.Variables.AppendDefaultValue "Office2007_2010_VSTO_Installed", "TRUE"
                            Else
                                NwEngine.Context.Log.Write "RegKey '" & szRegKey32 & "' found, but Value 'DisplayVersion' is not present! -> VSTO not installed correctly"
                            End If
                        Else
                            NwEngine.Context.Log.Write "VSTO 4.0 not found!"
                        End If
                    End If
                Else
                    NwEngine.Context.Log.Write "Microsoft Office 2007 or 2010 is not installed, VSTO will not be searched"
                End If
		]]></Value>
	</Variable>
</SapSetup>
