Joannes Vermorel
Joannes Vermorel

Reputation: 9245

Scripting a GUI from within a Windows Service?

I would like to automate a windows app that comes only with as a GUI app (no support for command-line). The automation itself is relatively straightforward with AutoIt.

Yet, I am wondering, is-it possible to launch the Windows App from with a windows service (that would simply call the AutoIt script)?

Upvotes: 1

Views: 860

Answers (2)

CoreTech
CoreTech

Reputation: 2433

While not at all advised because of complications associated with Session 0 isolation in the latest versions of Windows, AutoIt scripts can certainly be invoked from a Windows Service. Please see this page for a few sample scripts that work as expected when called from a Windows Service.

Unfortunately though, not all of the AutoIt functions seem to work in Session 0. We ran into trouble with the "Win*" routines (WinActivate, WinExists) so you should probably avoid those if you can. And since the documentation does not highlight the problematic functions be sure test thoroughly!

Upvotes: 1

Johan Buret
Johan Buret

Reputation: 2634

Even if Auto-it can work with UAC, you will most likely run into Session Isolation troubles - i.e services and desktop don't mix and send messages to each other, unless explicitely coded to pass through it.

So it's possible, but it's not a piece of cake either.

You probably want to look at : Launching a .Net winforms application interactively from a service

Upvotes: 2

Related Questions