When trying to open a window for the logged in user using Octopus, the application is instead opened as a background process with no visible window.
Start-Process chrome.exe
The response from octopus support is that this is not supported since Octopus runs as a background service, and so you cannot open any windows. We found a solution to that problem in the following code.
Input Parameters:
#{BinaryPath}
#{ErrorOnNonExist} = True
#{User}
– the user account to run this application under
Code:
if ($ErrorOnNonExist -eq "False") {
Write-Host "Looking for [$BinaryPath]"
$pathFound = Test-Path $BinaryPath
if (!$pathFound) {
Write-Host "File not found: [$BinaryPath]"
return
}
}
$taskName = "Start Process"
$taskWaitSeconds = 3
Get-ScheduledTask -TaskName $taskName -ErrorAction SilentlyContinue | Unregister-ScheduledTask $taskName -Confirm:$false
$triggerTime = (Get-Date).AddSeconds($taskWaitSeconds).ToString("HH:mm:ss")
$action = New-ScheduledTaskAction -execute $BinaryPath
$trigger = New-ScheduledTaskTrigger -once -at $triggerTime
Register-ScheduledTask -User $User -action $action -trigger $trigger -taskname $taskname -description "OctopusDeploy Start-Process workaround"
Write-Host "Starting [$BinaryPath]"
Start-Sleep -s $taskWaitSeconds #needed in case there are 2+ steps of this run one after the other
Just wanted to share this solution we found.