diff --git a/Install-Enscape.ps1 b/Install-Enscape.ps1 index a0589b1..aaab027 100644 --- a/Install-Enscape.ps1 +++ b/Install-Enscape.ps1 @@ -1,15 +1,40 @@ -## Path to the MSI installer -$MSIURL = 'https://enscape-installer.chaosgroup.com/installer.enscape.io/Enscape-4.0.0.579.exe' +# Path to the MSI installer +$URL = 'https://enscape-installer.chaosgroup.com/installer.enscape.io/Enscape-4.0.0.579.exe' -## Run the installer -$INSTALLER = Download-File -URL $MSIURL -Write-Output "Installing Enscape from ""${INSTALLER}""" -Try { Start-Process "msiexec.exe" -ArgumentList "/i ${INSTALLER} /qn /norestart ACCEPTEULA=1 ALLUSERS=1" -Wait -ErrorAction Stop } -Catch { Write-Error $_.Exception.Message } +# Set path to temp directory +$TEMPDIR = '{0}enscape-installer' -f (Get-TempPath) -## Delete installer -Try { - Write-Output "Deleting downloaded installation package" - Remove-Item $INSTALLER -Force -ErrorAction SilentlyContinue +# Recursively delete $TEMPDIR if it already exists +If ( Test-Path $TEMPDIR ) { + Write-Output """${TEMPDIR}"" already exists and will be deleted" + Try { Remove-Item -Path $TEMPDIR -Recurse -Force -ErrorAction SilentlyContinue } + Catch { Write-Error $_.Exception.Message } } -Catch { Write-Error $_.Exception.Message } + +# Create $TEMPDIR +Write-Output "Creating: ${TEMPDIR}" +Try { New-Item -Path $TEMPDIR -ItemType Directory -Force -ErrorAction Stop } +Catch { Write-Error $_.Exception.Message ; Return } + +# Write $CONFIG to config.xml +$CONFIG = @' + + 1 + C:\Program Files\Enscape + 1 + 1 + en-US + 1 + 1 + + +'@ +Try { $CONFIG | WriteToFile_UTF8NoBOM -FilePath "${TEMPDIR}\config.xml" } +Catch { Write-Output "Cannot write configuration file! This script will exit." ; Write-Error $_.Exception.Message ; Return } + +# Download the installer +$Installer = "${TEMPDIR}\$(Split-Path $URL -Leaf)" +Download-File -URL $URL -File $Installer + +# Install package +Install-Program -Path $Installer -Arguments "-gui=0 -acceptEULA -configFile=""config.xml"" -quiet=1 -ignoreErrors=1" -Delete