# ===================================================================================================
# Installation
# ===================================================================================================

# Removed Files/Folders
## REMOVED FILES MACHINE ##

# Copy Files/Folders
## COPY FILES MACHINE ##

# Removed Registry Keys
## REMOVED KEYS MACHINE ##

# Changed Registry Keys
## CHANGED KEYS MACHINE ##
 
# Added Registry Keys
## ADDED KEYS MACHINE ##

# Shortcuts
## SHORTCUTS MACHINE ##



# ===================================================================================================
# Some Examples - Delete if they are not needed
# ===================================================================================================

# Check OSType
If ((SF-Variables "%_OSType%") -eq "x64") {SF-Exit "This Software is only for Windows 32bit"}
If ((SF-Variables "%_OSType%") -eq "x86") {SF-Exit "This Software is only for Windows 64bit"}

# No install on Workstation and Notebook
If ((SF-Variables "%_ComputerType%") -eq "WORKSTATION") {SF-Exit "This Software is not for Workstations. Exit Installation"}
If ((SF-Variables "%_ComputerType%") -eq "NOTEBOOK") {SF-Exit "This Software is not for Notebooks. Exit Installation"}

# Load Variables
SF-LoadVariables "%c_ConfigPath%\%_PkgCFGName%.cfg" "CommonClientSettings"
If ((SF-Variables "%_VarPrefix-XXX%") -eq "") {SF-Exit "Value for Variable <XXX> must be set in %_PkgCFGName%.cfg"}

# Close Application
SF-Taskkill "Prima5.exe"
SF-Taskkill "%_ProgramFiles32%\Example"

# Language (Machine) - Function to create _PkgLang Variable
SF-Language "1031,1033,1036,1040" "1033"

# DEU
If ((SF-Variables "%_PkgLang%") -eq "1031") {
    SF-Register32 "HKey_Local_Machine" "Software\Application123" "Language" "de-DE" "REG_SZ"
}
# ENU
ElseIf ((SF-Variables "%_PkgLang%") -eq "1033") {
    SF-Register32 "HKey_Local_Machine" "Software\Application123" "Language" "en-US" "REG_SZ"
}
# FRA
ElseIf ((SF-Variables "%_PkgLang%") -eq "1036") {
    SF-Register32 "HKey_Local_Machine" "Software\Application123" "Language" "fr-FR" "REG_SZ"
}
# ITA
ElseIf ((SF-Variables "%_PkgLang%") -eq "1040") {
    SF-Register32 "HKey_Local_Machine" "Software\Application123" "Language" "it-it" "REG_SZ"
}

# If Product installed, then uninstall
SF-MSIUninstallByDisplayName "Java(TM) 6"

# Installation
SF-MSIInstall "%_PkgSource%\Setup\PrimaClient.msi" "ALLUSERS='1' /qn /norestart" -RemoveFirstOnRepair

# Installation - x86 and x64
SF-MSIInstall "%_PkgSource%\Setup\x86\vcredist.msi" "ALLUSERS='1' /qn /norestart"
 
# Installation - x64
SF-MSIInstall "%_PkgSource%\Setup\x64\vcredist.msi" "ALLUSERS='1' /qn /norestart" -x64

# Installation Silent
SF-Run "%_PkgSource%\Setup\CitrixReceiverEnterprise.exe" "/silent /noreboot SERVER_LOCATION='%_VarPrefix-ServerLocation%'" -Wait

# Installation Silent with MSI Repair - Only use this when the original Setup is a EXE (With the function SF-MSIInstall the repair start automatically)
If ((SF-Installed "{D0CC22F6-A67A-4083-A043-E0640CB7A4DF}") -eq $true) {
    SF-MSIRepair "{D0CC22F6-A67A-4083-A043-E0640CB7A4DF}" "/qn /norestart"
} 
Else {
    SF-Run "%_PkgSource%\Setup\Install.exe" "/S" -Wait
}

# Run with excluded Error Codes separated by commas - (0, 1605, 1641 and 3010 are always and per default excluded)
SF-Run "%_PkgSource%\Setup\Install.exe" "/S" -Wait -ExcludedExitCodes "256,1024"

# Check File
If ((SF-File "%_ProgramFiles32%\Orca\Orca.exe") -eq $true) {
    SF-Log "Orca found"
}

# Copy Files
SF-Copy "%_PkgSource%\Setup\ProgramFiles32" "%_ProgramFiles32%" -Newer
SF-Copy "%_PkgSource%\Setup\Windows" "%_Windows%" -Newer
SF-Copy "%_PkgSource%\Setup\WindowsSystem32" "%_WindowsSystem32%" -Newer
SF-Copy "%_PkgSource%\Setup\PrimaMGB.dll" "%_ProgramFiles32%\Prima5\Bin" -Newer

# Set Permission
SF-NTFSPerm "%_ProgramFiles32%\SubFolder" "%_GroupUsers%" "Modify"
SF-NTFSPerm "%_ProgramFiles32%\XXX.ini" "%_GroupUsers%" "Full"

# Create Shortcut
SF-Shortcut "%_CommonPrograms%\RegShot\Regshot-x86-ANSI.lnk" "%_ProgramFiles32%\RegShot\Regshot-x86-ANSI.exe" "%_ProgramFiles32%\RegShot" "%_ProgramFiles32%\RegShot\Regshot-x86-ANSI.exe,0" "Regshot x86 ANSI"

# Remove Shortcuts
SF-Delete "%_CommonDesktop%\XXX.lnk"
SF-RD "%_CommonPrograms%\XXX"

# Remove Shortcuts if CITRIX
If ((SF-Variables "%_ComputerType%") -eq "CITRIX") {
    SF-RD "%_CommonPrograms%\XXX"
    SF-Delete "%_CommonStartUp%\XXX.lnk"
}

# System Reboot
SF-SystemReboot

# ===================================================================================================
# END
# ===================================================================================================