简体   繁体   English

是否可以将 UI 自动化作为 Windows 服务运行?

[英]Is it possible to run UI Automation as a Windows service?

I have a Windows VM with a desktop application on it.我有一个带有桌面应用程序的 Windows VM。 I want to write an agent which will interact with this application through UI automation (via WinAppDriver ).我想编写一个代理,它将通过 UI 自动化(通过WinAppDriver )与这个应用程序交互。 The agent should start with the machine and require as little human intervention as possible to do its job.代理应该从机器开始,并且需要尽可能少的人工干预来完成其工作。

It's easy enough to get this working by adding it to startup programs (shell:startup), but this requires someone logging into the VM every time it is restarted.通过将其添加到启动程序 (shell:startup) 可以很容易地使其工作,但这需要有人在每次重新启动 VM 时登录。 Is it possible to run such a program as a Windows Service?是否可以运行 Windows 服务之类的程序? Keep in mind it would have to launch a Win32 app and interact with it via UI automation.请记住,它必须启动一个 Win32 应用程序并通过 UI 自动化与之交互。 Could this be done by running it as Local System account and enabling "Allow service to interact with desktop"?这可以通过将其作为本地系统帐户运行并启用“允许服务与桌面交互”来完成吗? Or would it need to run as a specific user account?还是需要以特定用户帐户的身份运行?

No, it is because Windows Service runs in background and to access the UI the process should run foreground.不,这是因为 Windows 服务在后台运行,并且要访问 UI,该进程应该在前台运行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM