Application of the week > Application of the Week – Slack

Slack provides collaboration software using channels which can be divided up by team, project, client, or whatever else is relevant to your organization.

In your email inbox, seeing all the conversations about a single project requires sifting through many different email chains. In Slack, you’ll save time by seeing all the discussions and files about a project in one place: a channel. Team members can join and leave channels as needed. In this blog I will explain how to create a Smart Icon for Slack.

Slack has two MSI’s available to install Slack for Windows. One MSI is for per-user deployment. One is for machine wide-installation. That’s the one we need. This MSI is therefore available in the Liquit Setup Store.

Let’s create a managed package in Liquit Workspace for Slack using the Setup Store connector:

  • Click Manage, Connector, then select the Setup Store connector
  • Click Resources and search for ‘Slack’
  • Select either one of the available ‘Slack’ setups, either for 32 or 64 bit
  • Click ‘Create Package’
  • In the Details screen opt for ‘Package Type = Managed’
  • Click ‘Next’
  • In the Entitlements screen add the users you want to assign this package to
  • In the Summary screen uncheck the ‘Modify package after creation’ checkbox
  • Click ‘Finish’

The Setup Connector now grabs the latest version of the selected Slack setup and creates a Managed Package for it. ‘Managed’ means that every time Slack releases a new version of Slack for Windows, the Setup Store connector updates all your managed packages with the latest version of that particular application.

You can do this automatically, using a scheduled task, or semi-automatically using the ‘Updates’ feature of the Setup Store connector. This managed package takes care of installing Slack for Windows.

Let’s focus at the Smart Icon now. This Smart Icon contains three actions in one Launch action set for which ‘Stop at first effective action’ is set:

  • the first action runs the slack.exe executable, this executable is installed when using the Slack Machine-Wide Installer Managed Package
  • the second action launches the Slack Microsoft Store app. In my blogs about Netflix, Deezer and Microsoft Calculator I’ve discussed how to deal with Appx packages. Using the techniques described in these blogs, an action for the Slack store app is similar. The Microsoft Store app and Slack for Windows don’t differ that much in terms of features.
  • the third action uses your default browser to launch the Slack url https://app.slack.com/client when Slack for Windows and the Slack Microsoft Store app are not installed (yet).

Here’s the PowerShell script to create a Smart Icon for Slack:

Import-Module "C:\Program Files (x86)\Liquit Workspace\PowerShell\3.0\Liquit.Server.PowerShell.dll" -Prefix "Liquit"

$liquitZoneUsername = "local\admin"
$liquitZonePassword = Read-Host "Enter Password" -AsSecureString
$liquitCredentials = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $liquitZoneUsername, $liquitZonePassword
$liquitZone = "https://yourliquitzone.liquit.com"

$slackIconURL = "https://www.setupcommander.com/ico/slack.ico"
$slackIconPath = "c:\temp\slack.ico"

$webClient = New-Object System.Net.WebClient
$webClient.DownloadFile($slackIconURL, $slackIconPath)
$iconContent = New-LiquitContent -Path $slackIconPath 

$packageName = "Slack"
$packageDisplayName = "Slack"
$packageDescription = "Slack"

$liquitContext = Connect-LiquitWorkspace -URI $liquitZone -Credential $liquitCredentials

$package = New-LiquitPackage -Name $packageName `
                             -Type "Launch" `
                             -DisplayName $packageDisplayName `
                             -Description $packageDescription `
                             -Priority 100 `
                             -Enabled $true `
                             -Offline $True `
                             -Web $true `
                             -Icon $iconContent 

#create the snapshot for this package
$snapshot = New-LiquitPackageSnapshot -Package $package

#define launch action set
$actionset = New-LiquitActionSet -snapshot $snapshot `
                                 -Type Launch `
                                 -name 'Launch' `
                                 -Enabled $true `
                                 -Frequency Always `
                                 -Process StopAtFirstEffectiveAction

#
#define the first launch action
#
$actionset_action1 = New-LiquitAction -ActionSet $actionset `
                                      -Name 'Start Slack for Windows' `
                                      -Type 'processstart' `
                                      -Enabled $true `
                                      -IgnoreErrors $false `
                                      -Settings @{name = '${ProgramFiles}\Slack Deployment\slack.exe'; parameters = "";} `
                                      -Context User


#define the filter set for the first action
$filterset1 = New-LiquitFilterSet -Action $actionset_action1

#add a filter to the first action
$filter1_1 = new-LiquitFilter -FilterSet $filterset1 -type fileexists -Settings @{path = '${ProgramFiles}\Slack Deployment\slack.exe';} -Value "true" 


#set the operator for the entity filter to AND
Set-LiquitEntityFilter -Action $actionset_action1 -Operator Or


#
#define the second launch action
#
$actionset_action2 = New-LiquitAction -ActionSet $actionset `
                                      -Name 'Start Slack Microsoft Store App' `
                                      -Type 'processstart' `
                                      -Enabled $true `
                                      -IgnoreErrors $false `
                                      -Settings @{name = '${SystemRoot}\explorer.exe'; parameters = "Shell:AppsFolder\91750D7E.Slack_8she8kybcnzg4!Slack";} `
                                      -Context User

#define the filter set for the third action
$filterset2 = New-LiquitFilterSet -Action $actionset_action2

#add a filter to the first action
$filter2_1 = new-LiquitFilter -FilterSet $filterset2 -type fileexists -Settings @{path = '${ProgramFiles}\WindowsApps\91750D7E.Slack_4.4.0.0_x64__8she8kybcnzg4\AppxManifest.xml';} -Value "true"
                                                                       
#
#define the third launch action
#
$actionset_action3 = New-LiquitAction -ActionSet $actionset `
                                      -Name 'Open Slack Workspace on the web' `
                                      -Type 'openurl' `
                                      -Enabled $true `
                                      -IgnoreErrors $false `
                                      -Settings @{ url = 'https://app.slack.com/client'; browser = 0;} `
                                      -Context User


#publish the package
Publish-LiquitPackageSnapshot -Snapshot $snapshot -stage Production 

#set the entitlement
$identity = Get-LiquitIdentity -id "LOCAL\everyone"
New-LiquitPackageEntitlement -Package $package -Identity $identity -Publish Workspace

About the author