Octopus.Script exported 2018-05-04 by sphinxy belongs to ‘Windows’ category.
Change binary path of existing windows service (changes will be effective after service start/stop)
Parameters
When steps based on the template are included in a project’s deployment process, the parameters below can be set.
Service name to change binary path.
ServiceName =
Name of the service to change. Example: OctopusService
Binary path
BinaryPath =
Path to the new service binary. Example: c:\services\octopus.exe
Script body
Steps based on this template will execute the following PowerShell script.
$TheService = Get-Service $ServiceName -ErrorAction SilentlyContinue
if ($TheService)
{
Write-Host "Windows Service ""$ServiceName"" found, changing path."
sc.exe config $TheService binPath= $BinaryPath
Write-Host "Service ""$ServiceName"" path changed to ""$BinaryPath"", restart service to use new path."
}
else
{
Write-Host "Windows Service ""$ServiceName"" not found."
}
Provided under the Apache License version 2.0.
To use this template in Octopus Deploy, copy the JSON below and paste it into the Library → Step templates → Import dialog.
{
"Id": "b6860fcf-9dee-48a0-afac-85e2098df692",
"Name": "Windows Service - Change binary path",
"Description": "Change binary path of existing windows service (changes will be effective after service start/stop)",
"Version": 2,
"ExportedAt": "2018-05-04T08:38:54.450Z",
"ActionType": "Octopus.Script",
"Author": "sphinxy",
"Parameters": [
{
"Id": "b6cfb2c2-7bfd-4d28-ab91-f9f114c2c0dd",
"Name": "ServiceName",
"Label": "Service name to change binary path.",
"HelpText": "Name of the service to change. Example: OctopusService",
"DefaultValue": "",
"DisplaySettings": {
"Octopus.ControlType": "SingleLineText"
},
"Links": {}
},
{
"Id": "d2e685d0-e244-450f-82eb-c435462cdb0f",
"Name": "BinaryPath",
"Label": "Binary path",
"HelpText": "Path to the new service binary. Example: c:\\services\\octopus.exe",
"DefaultValue": "",
"DisplaySettings": {
"Octopus.ControlType": "SingleLineText"
},
"Links": {}
}
],
"Properties": {
"Octopus.Action.Script.ScriptSource": "Inline",
"Octopus.Action.Script.Syntax": "PowerShell",
"Octopus.Action.Script.ScriptBody": "$TheService = Get-Service $ServiceName -ErrorAction SilentlyContinue\nif ($TheService)\n{\n Write-Host \"Windows Service \"\"$ServiceName\"\" found, changing path.\"\n sc.exe config $TheService binPath= $BinaryPath\n Write-Host \"Service \"\"$ServiceName\"\" path changed to \"\"$BinaryPath\"\", restart service to use new path.\"\n}\nelse\n{\n Write-Host \"Windows Service \"\"$ServiceName\"\" not found.\"\n}\n",
"Octopus.Action.Package.DownloadOnTentacle": "False"
},
"Category": "Windows",
"HistoryUrl": "https://github.com/OctopusDeploy/Library/commits/master/step-templates//opt/buildagent/work/75443764cd38076d/step-templates/windows-service-change-binary-path.json",
"Website": "/step-templates/b6860fcf-9dee-48a0-afac-85e2098df692",
"Logo": "iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAMAAACahl6sAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAADNQTFRF////Da3qSsLvhtb0wur6O7zuWcfxldv2aMzyK7ftpOD3s+X48Pr+0fD7d9HzHLLr4fX8xD/OcwAAAaNJREFUeNrs3cFygjAUQFECWott1f//2sJoW6kIKEzNs+euXOmcmSSGDa8oJEmSJEmSJGmsj1W1K9cpsGD1Vr2WdToVEPC+2lYvZfpVrEW0qZpF1F+MRdRugzoNlvkiarfBPk0pT8GhWUSX2yASpDlLr2+DEJBmEY1ug6whx7N0n2b30G1QlmmxHsRYp6X76yvF9vg5RYQczq8UVURI35UiFmTgShED0p6lI1eKzCHTrxS5Qk6PZ9PLDtJ9PIsJmXWlyAky6/dAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQMJCyjltF/iO3gpJUpD8s4OAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgID8T8itwwKyhbTdMr4ha8hXUwZqhICcOgyNOIkE+V5wo4MSgr1u/fp7poO+AL8K/gL8yw0UeyRB34m9iQ/pVD8L5JYTO3NI58R+AsiEEzsW5OfE3sUe/zRwYkeGnG2g2CPS7rhjF4GKP0ZwyoldxK37kFqEL/7wU0mSJEmSJOmJ+xRgAHxZTCXGdZkfAAAAAElFTkSuQmCC",
"$Meta": {
"Type": "ActionTemplate"
}
}
Page updated on Friday, May 4, 2018