-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall-service.ps1
More file actions
79 lines (72 loc) · 2.19 KB
/
install-service.ps1
File metadata and controls
79 lines (72 loc) · 2.19 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
# Download and install winsw, then use it to periodically run our script
# Turn debugging on/off
$DebugPreference = "Continue"
# Set vars
$installdir = "$Env:ProgramFiles\steam-update-disable-service"
Write-Debug $installdir
# Ensure installdir exists
if ( -not (Test-Path $installdir) ) {
New-Item -ItemType Directory -Path $installdir
}
# Download winsw
$winsw_url = "https://github.com/winsw/winsw/releases/download/v2.10.3/WinSW.NETCore31.x86.exe"
$winsw_dest = "$installdir\steam-update-disable-service.exe"
if ( -not (Test-Path $winsw_dest) ) {
Invoke-WebRequest -Uri $winsw_url -OutFile $winsw_dest
}
# Install our files
$scripts = @(
"steam-update-disable-service.ps1"
)
ForEach ($script in $scripts) {
Copy-Item -Path "$PSScriptRoot\$script" -Destination "$installdir\$script"
}
# write steam-update-disable-service.yml
$winsw_yaml = @"
id: DisableSteamAutoUpdate
name: DisableSteamAutoUpdate
description: Service to periodically disable Steam Auto-Update on all Steam Games
onFailure:
- action: 'restart'
delay: '60 sec'
- action: 'restart'
delay: '300 sec'
- action: 'restart'
delay: '600 sec'
resetfailure: '1 hour'
#securityDescriptor: security descriptor string
executable: 'PowerShell.exe'
arguments: >-
-ExecutionPolicy Bypass
-File "$installdir\steam-update-disable-service.ps1"
#startArguments: start arguments
#workingdirectory: C:\myApp\work
priority: 'Normal'
stopTimeout: '15 sec'
stopParentProcessFirst: true
#stopExecutable: '%BASE%\stop.exe'
#stopArguments: -stop true
startMode: 'Automatic'
#delayedAutoStart: true
#serviceDependencies:
# - Eventlog
# - W32Time
waitHint: '15 sec'
sleepTime: '1 sec'
#interactive: true
log:
# logpath: '%BASE%\logs'
mode: 'append'
#beepOnShutdown: true
"@
$winsw_yaml | Out-File "$installdir\steam-update-disable-service.yml"
# install service
& $installdir\steam-update-disable-service.exe stop
& $installdir\steam-update-disable-service.exe uninstall
& $installdir\steam-update-disable-service.exe install
$installcode = $LastExitCode
if ($installcode -ne 0) {
& $installdir\steam-update-disable-service.exe uninstall
throw "Couldn't install. Exit code is $installcode"
}
& $installdir\steam-update-disable-service.exe start