-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathinstall.ps1
51 lines (44 loc) · 1.49 KB
/
install.ps1
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
# This script will download and install Dividat Driver as a Windows service.
## Configuration ##########################################
$releaseUrl = "https://dist.dividat.com/releases/driver2/"
$channel = "main"
$installDir = "C:\Program Files\dividat-driver"
###########################################################
$ErrorActionPreference = "Stop"
# Figure out the latest version
$latestTmpFile = Join-Path $env:TEMP "dividat-driver-latest.txt"
try {
(New-Object System.Net.WebClient).DownloadFile($releaseUrl + $channel + "/latest",$latestTmpFile)
}
catch {
$ex = $_
while ($ex -eq $null)
{
Write-Host $ex.Message
Write-Host $ex.ScriptStackTrace
$ex = $ex.InnerException
}
}
$latest = (Get-Content $latestTmpFile -Raw).trim()
Remove-Item -path $latestTmpFile
# Create install directory
if (![System.IO.Directory]::Exists($installDir)) {[void][System.IO.Directory]::CreateDirectory($installDir)}
# Download application
$downloadUrl = $releaseUrl + $channel + "/" + $latest + "/" + "dividat-driver-windows-amd64-" + $latest + ".exe"
$appPath = Join-Path $installDir "dividat-driver.exe"
try {
(New-Object System.Net.WebClient).DownloadFile($downloadUrl,$appPath)
}
catch {
$ex = $_
while ($ex -eq $null)
{
Write-Host $ex.Message
Write-Host $ex.ScriptStackTrace
$ex = $ex.InnerException
}
}
# Install as service
New-Service -Name "DividatDriver" -BinaryPathName $appPath -DisplayName "Dividat Driver" -StartupType Automatic
# Start the service
Start-Service DividatDriver