Last active
July 8, 2020 13:32
-
-
Save knuton/040665243300a50d42215ae2a5627569 to your computer and use it in GitHub Desktop.
Install dividat driver as Windows service
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This script will download and install Dividat Driver as a Windows service. | |
## Configuration ########################################## | |
$releaseUrl = "https://dist.dividat.com/releases/driver2/" | |
$channel = "master" | |
$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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This script will download and install Dividat Driver as a Windows service. | |
## Configuration ########################################## | |
$releaseUrl = "https://dist.dividat.com/releases/driver2/" | |
$channel = "master" | |
$installDir = "/home/emerij/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 | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment