Actions

Application Management Examples

From Syntaro Help

We assume, that you are using our Base Script provided on Github in all of your examples.

Standard MSI Application

Detection Script

if(Get-InstalledApplication -ProductCode "{AAB53BA7-A155-49A9-AC85-DB1A14F5457F}"){
    $true
} else {
    $false
}

Requirements Script

$True

Install Script

Execute-MSI -Action Install -Path YourMSI.msi

Uninstall Script

Execute-MSI -Action Uninstall -Path "{AAB53BA7-A155-49A9-AC85-DB1A14F5457F}"

EXE Setup with App Content in ZIP File

If you have a lot of files, it is easier to distribute it as a single ZIP file. This example shows how to extract the ZIP file and start the setup EXE.

Detection Script

If(Get-InstalledApplication -name "MyApp"){
    $True
}
else{
    $False
}

Requirements Script

# No requirements needed
$true

Install Script

# Unpack install sources
$temp = $env:TEMP
$unpack = $temp + "\$PackageName"
Expand-Zip  -File "$ScriptPath\MyContent.zip" -Destination $unpack
$execute = $unpack + "\setup.exe"

# Install application
Execute-Exe -Path $execute -Arguments "/s" 

# Remove sources
start-sleep -s 10
Remove-Item $unpack -Force -Recurse

Uninstall Script

# Unpack install sources
$temp = $env:TEMP
$unpack = $temp + "\$PackageName"
Expand-Zip  -File "$ScriptPath\MyContent.zip" -Destination $unpack
$execute = $unpack + "\setup.exe"

# Install application
Execute-Exe -Path $execute -Arguments "/s /uninstall" 

# Remove sources
start-sleep -s 10
Remove-Item $unpack -Force -Recurse

Force Reboot after Installation

Sometimes it's required to reboot a computer after an application is installed. You can do that easily by calling shutdown.exe. With the /t parameter, you are able to adjust when the reboot should happen:

Execute-Exe -Path "C:\Windows\System32\shutdown.exe" -Parameters "/g /t 300 /f /d p:4:2 /c `"Active User Setup was installed and needs a reboot.`""

Then the Users will get the following experience:

Force Reboot App Management Experience

Check for Installed Version during Detection

Often it is required to check if the correct version is installed or for example if a specific minimum version is installed. This is helpful when the users perhaps update the application themselves or some other Updaters are updating the app.

Important is, that the version has to be in a correct version format(major.minor[.build[.revision]]), where each element has to be a positive integer. With the VersionComparison parameter you can define:

  • gt: Greater than
  • ge: Greator or equals than (Default)
  • eq: equals
  • le: Lower or equals than
  • lt: Lower than



So if the application has to be available with a specific minimal version, you can just use the following syntax:

If(Get-InstalledApplication -name "MyApp" -Version "20.15.8.0"){
    $True
}
else{
    $False
}



If you require some other comparison then you can use the following:

If(Get-InstalledApplication -name "MyApp" -Version "20.15.8.0" -VersionComparison eq){
    $True
}
else{
    $False
}