<job id="Install-BGInfo">
<script language="VBScript" src="..\..\scripts\ZTIUtility.vbs"/>
<script language="VBScript"> 

'//----------------------------------------------------------------------------
'// Solution: Hydration
'// Purpose: Used to install BGInfo 
'// Usage: cscript Install-Install-BGInfo.wsf [/debug:true]
'// Version: 1.0 - 12 Dec 2011 - Johan Arwidmark
'//
'// This script is provided "AS IS" with no warranties, confers no rights and 
'// is not supported by the authors or Deployment Artist. 
'//
'//----------------------------------------------------------------------------

'//----------------------------------------------------------------------------
'// Global constant and variable declarations
'//---------------------------------------------------------------------------- 

Option Explicit 
Dim iRetVal 

'//----------------------------------------------------------------------------
'// End declarations
'//---------------------------------------------------------------------------- 

'//----------------------------------------------------------------------------
'// Main routine
'//---------------------------------------------------------------------------- 

On Error Resume Next
iRetVal = ZTIProcess
ProcessResults iRetVal
On Error Goto 0 

'//---------------------------------------------------------------------------
'//
'// Function: ZTIProcess()
'//
'// Input: None
'// 
'// Return: Success - 0
'// Failure - non-zero
'//
'// Purpose: Perform main ZTI processing
'// 
'//---------------------------------------------------------------------------
Function ZTIProcess() 

    Dim sSetupFile
    Dim sFolder

    oLogging.CreateEntry "Install-BGInfo: Starting", LogTypeInfo
    
    ' Copy Bginfo.lnk to All Users Startup Folder
	sSetupFile = oUtility.ScriptDir & "\Source\Bginfo.lnk"
    sFolder = oShell.SpecialFolders("AllUsersStartup") & "\"
    If not oFSO.FileExists(sSetupFile) then
        oLogging.CreateEntry "Install-BGInfo: " & sSetupFile & " was not found, unable to install BGInfo", LogTypeInfo
        ZTIProcess = Failure
		Exit Function
	End if
    oFSO.GetFile(sSetupFile).Copy sFolder & oFSO.GetFileName(sSetupFile),True	

    ' Create the C:\Program Files\BGInfo folder
    sFolder = "C:\Program Files\BGInfo\"
    oFSO.CreateFolder sFolder

    ' Copy Custom.bgi to C:\Program Files\BGInfo
	sSetupFile = oUtility.ScriptDir & "\Source\Custom.bgi"
    If not oFSO.FileExists(sSetupFile) then
        oLogging.CreateEntry "Install-BGInfo: " & sSetupFile & " was not found, unable to install BGInfo", LogTypeInfo
        ZTIProcess = Failure
		Exit Function
	End if
    oFSO.GetFile(sSetupFile).Copy sFolder & oFSO.GetFileName(sSetupFile),True	

    ' Copy CustomBginfo.exe to C:\Program Files\BGInfo
   	sSetupFile = oUtility.ScriptDir & "\Source\Bginfo.exe"
    If not oFSO.FileExists(sSetupFile) then
        oLogging.CreateEntry "Install-BGInfo: " & sSetupFile & " was not found, unable to install BGInfo", LogTypeInfo
        ZTIProcess = Failure
		Exit Function
	End if
    oFSO.GetFile(sSetupFile).Copy sFolder & oFSO.GetFileName(sSetupFile),True	

   	' Run BGInfo
   	sSetupFile = "C:\Program Files\BGInfo\Bginfo.exe"
    If not oFSO.FileExists(sSetupFile) then
        oLogging.CreateEntry "Install-BGInfo: " & sSetupFile & " was not found, unable to run BGInfo", LogTypeInfo
        ZTIProcess = Failure
		Exit Function
	End if
	iRetVal = oShell.Run("""" & sSetupFile & """ ""C:\Program Files\BGInfo\Custom.bgi"" /timer:0 /silent /nolicprompt", 0, True)

	oLogging.CreateEntry "Install-BGInfo: Finished", LogTypeInfo
	
End Function 

</script>
</job>