-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstallMissive-AllUsers.ps1
More file actions
110 lines (95 loc) · 3.69 KB
/
Copy pathinstallMissive-AllUsers.ps1
File metadata and controls
110 lines (95 loc) · 3.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
<#
.SYNOPSIS
Installs Missive email client for all users on Windows.
.DESCRIPTION
This script performs an automated installation of Missive email client:
- Checks if Missive is already installed
- Downloads the latest Missive installer
- Performs a silent installation for all users
- Creates shortcuts in public Start Menu and Desktop
- Cleans up temporary files
.NOTES
Version: 2.0
Last Updated: 2025
Requires: PowerShell 5.1 or later
Run with administrative privileges
#>
param (
[Parameter(Mandatory = $false)]
[string]$InstallPath = "$env:SystemDrive\Missive"
)
Set-ExecutionPolicy Unrestricted
$ProgressPreference = 'SilentlyContinue'
$softwareName = 'Missive'
$checkLocation = 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Uninstall'
$installerUrl = 'https://mail.missiveapp.com/download/win'
$tempPath = "$env:SystemDrive\Temp"
$missiveFile = "$tempPath\MissiveSetup.exe"
# Function to remove Missive installer and temp files
function Remove-TempFiles {
try {
Write-Host "Cleaning up temporary files and folders..."
if (Test-Path $missiveFile) { Remove-Item $missiveFile -Force }
if (Test-Path $tempPath) { Remove-Item $tempPath -Force }
Start-Sleep -Seconds 2
} catch {
Write-Host -BackgroundColor Red -ForegroundColor White " Error: Failed to remove temporary files "
Write-Host $_.Exception.Message
Start-Sleep -Seconds 3
}
}
# Check if Missive is already installed
if (Get-ChildItem $checkLocation -Recurse -ErrorAction Stop |
Get-ItemProperty -name DisplayName -ErrorAction SilentlyContinue |
Where-Object {$_.DisplayName -Match "^$softwareName.*"}) {
Write-Host -ForegroundColor Yellow "$softwareName is already installed. No action required."
exit
}
Write-Host -ForegroundColor Yellow "$softwareName is NOT installed. Installing Now..."
# Create Temp Folder
[void](New-Item -ItemType Directory -Force -Path $tempPath)
# Download Missive installer
try {
Write-Host "Downloading Missive installer..."
Invoke-WebRequest -Uri $installerUrl -OutFile $missiveFile -ErrorAction Stop
} catch {
Write-Host -BackgroundColor Red -ForegroundColor White " Error: Download failed "
Write-Host $_.Exception.Message
Remove-TempFiles
exit 1
}
# Install Missive silently for all users
try {
Write-Host "Installing Missive for all users..."
$process = Start-Process -Wait -FilePath $missiveFile -ArgumentList "/S /D=$InstallPath" -PassThru
if ($process.ExitCode -ne 0) {
throw "Installation failed with exit code: $($process.ExitCode)"
}
} catch {
Write-Host -BackgroundColor Red -ForegroundColor White " Error: Installation failed "
Write-Host $_.Exception.Message
Remove-TempFiles
exit 1
}
# Create shortcuts for all users
try {
Write-Host "Creating shortcuts for all users..."
$missiveExecutable = "$env:SystemDrive\$softwareName\Missive.exe"
$WScriptObj = New-Object -ComObject ("WScript.Shell")
# Create Start Menu shortcut
$startMenuPath = "$env:ALLUSERSPROFILE\Microsoft\Windows\Start Menu\Programs\Missive.lnk"
$shortcutStart = $WscriptObj.CreateShortcut($startMenuPath)
$shortcutStart.TargetPath = $missiveExecutable
$shortcutStart.Save()
# Create Desktop shortcut
$desktopPath = "$env:Public\Desktop\Missive.lnk"
$shortcutDesktop = $WscriptObj.CreateShortcut($desktopPath)
$shortcutDesktop.TargetPath = $missiveExecutable
$shortcutDesktop.Save()
} catch {
Write-Host -BackgroundColor Red -ForegroundColor White " Error: Failed to create shortcuts "
Write-Host $_.Exception.Message
}
# Cleanup
Remove-TempFiles
Write-Host -ForegroundColor Green "Missive installation completed successfully!"