Winforms used as Services

Hi Guys

I really hope you can help. We have had 3 of us working on this, to no avail.

The problem: We have a very old legacy software estate. We have everything building in Team City, and are currently configuring Octopus Deploy to do what it’s good at.

As part of our estate, we have 2 Win-Forms applications that act as a service. They sit on a server doing their thing, and they have a GUI that occasionally gets used.

What we are trying to accomplish is to:

  • properly close the application (which requires the pushing of buttons so we don’t kill it in the middle of something important)
  • replace the required files (the easy bit. no problems here)
  • start up the application in the correct remote windows desktop session, and click a button to make it do its thing. (more button pushing)

We are trying to do these tricky bits with powershell?
For the poking of buttons we are using the good work at which is a UI Automation testing tool for powershell.

It’s worth noting that we can quite happily get the powershell working via Powershell ISE, but not through the Tentacle.

Starting the application is not too bad, but we have trouble with the remote button pushing. The below code works:

$filePath = “C:\Temp\Apps\ConfirmationsManager\ConfManager.exe”
$psexec = “C:\Temp\DesktopInteraction\PsExec.exe”

Start-Process $psexec " -i 2 -s $filePath"

Our issues are many, depending on what combination of things we try.

So, my question… Has anyone successfully accomplished similar to our scenario? If so, how? If not, then any idea’s on how to approach this anyway? We are pretty much nearing the end of our wits!!!



Hi Paul,

Thanks for getting in touch! I haven’t come across such as scenario previously. The Tentacle runs as a Windows Service, which would probably explain why it cannot interact with the desktop.

If you are able to update the Win-forms applications I’d probably approach it using a powershell script to “signal” that is wants the Win-Forms applications to shutdown, conceptually similar to how a CancellationToken can be used in C#. You could use a registry setting or existence of a file or something like that as the mechanics for the “signal”.

So the idea in the powershell script would be something like:

  1. Find the process Ids for the Win-forms apps
  2. Set the signal
  3. Wait until the processes are no longer running
  4. Clear the signal

The Win-form app then check for the “signal” periodically and shut down when they see it.

Hope that helps and let me know if I can assist further.


Thank you Shannon

I was starting to think along these lines myself, altering the actual app so that it listens or checks for something to tell it to close down…

Curse this ancient software. :slight_smile: