Skip to content
Snippets Groups Projects
Commit e776aa59 authored by Niko Ehrenfeuchter's avatar Niko Ehrenfeuchter :keyboard:
Browse files

Simple installer script for the updater.

parent 43677b84
No related branches found
No related tags found
No related merge requests found
$InstallDir = "C:\Tools\AutoTx-Updater"
$JobScript = "Update-Service.ps1"
$Config = "UpdaterConfig.inc.ps1"
if (Test-Path $InstallDir) {
Write-Host "ERROR: updater directory already existing, stopping installer!"
Write-Host "[$($InstallDir)]"
Exit
}
if (-Not (Test-Path $Config)) {
Write-Host "ERROR: no config file for the updater found!"
Write-Host "[$($Config)]"
Exit
}
New-Item -Force -Type Directory $InstallDir
Copy-Item $JobScript $InstallDir
Copy-Item $Config $InstallDir
# create a repetition interval
$TimeSpan = New-TimeSpan -Minutes 10
# configure a JobTrigger for the task using the repetition interval from above,
# repeating forever
$JobTrigger = New-JobTrigger `
-Once `
-At (Get-Date).Date `
-RepetitionInterval $TimeSpan `
-RepeatIndefinitely
# configure the JobOptions for the task (battery options should not be required
# on a fixed system, but doesn't hurt either)
$JobOptions = New-ScheduledJobOption `
-RunElevated `
-StartIfOnBattery `
-ContinueIfGoingOnBattery
# set credentials for running the task (requires permission to start/stop the
# service and overwriting the configuration and binaries)
$Cred = Get-Credential
# register the job for execution
Register-ScheduledJob `
-Name "AutoTx-Updater" `
-FilePath "$($InstallDir)\$($JobScript)" `
-ArgumentList "$($InstallDir)\$($Config)" `
-ScheduledJobOption $JobOptions `
-Trigger $JobTrigger `
-Credential $Cred `
-Verbose
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment