Blocking "Console.ReadKey"

I am using a third party console application to perform a control registration step that is required by the platform that runs my application. Unfortunately the exe has a ReadKey as the final step and there is currently no way to bypass it.

I started the deploy.ps1 just executing the file with & $cmd “params…” however when the script hit the ReadKey it just blocked.

I then tried executing the command with Start-Job/Wait-Job combination however while this was successful at registering my control, the exe threw an error when it tried to write to stdout. This results in octopus believing that the script failed.

Short of having the 3rd party vendor update the exe (which i have also requested) is there a way to address the situation of blocking readkey() in deployers?


Hi Clayton,

Thanks for getting in touch.

Do you know if the console app is specifically executing ReadKey? Or could it be calling ReadLine?

I made a simple console app and if I used ReadLine I could get around it by calling it like this in PowerShell:

write-output y | C:\Development\_tmp\ReadMeConsoleApp\ReadMe\bin\Debug\ReadMe.exe

But it doesn’t work if the console app is using ReadKey unfortunately (it throws an exception …and try/catch in PowerShell doesn’t work on native executables). So if it’s using ReadKey I’m not sure how to get around that I’m afraid.


Thanks Mark,
Yes I’ve decompiled and it is a read-key. At this point I’m just going to use the decompiled source and make my own PS module.

Hi Clayton,

Glad you’ve got a workaround (albeit a painful one). Hopefully the third-party vendor is able to give you an optional flag in the future :slight_smile: