在Windows Server 2008的Task Sheduler中使用UI运行应用程序 [英] Run application with UI in Task Sheduler on Windows Server 2008
问题描述
大家好,我需要在没有用户登录的情况下每5分钟在Windows Server 2008上运行WinForms应用程序.在旧的Windows版本中,启用了UI,但是现在,使用Session0隔离无法正确运行应用程序.我试图创建一个使用CreateProcessAsUser Win32 API函数运行我的应用程序的ScheduleRunner程序,但是它不能正常运行(UI不能正常运行).
我应该怎么做才能使其正常工作?
首先,谢谢.
Hi all, I need to run WinForms application on Windows Server 2008 every 5 minutes while no user is logged on. In old Windows versions UI was enabled, but now, with Session0 Isolation it is not possible to run application correctly. I tried to create a ScheduleRunner program that uses CreateProcessAsUser Win32 API function to run my application, but it does not work as well (UI is not working).
What should I do to get it working?
Thanks in advance.
推荐答案
首先,自从Vista OS发明以来,所有用户都在单独的会话中工作,该会话不同于会话0,并且它们具有适当的桌面会话的实例.
据我所知,没有用于会话0的桌面实例,而此会话用于NT服务
但是我可能错了.
借助WinApi方法
Hi first of all, since invention of Vista OS, all users works in separated session , which differs from Session 0, and they have appropriate desktop instance for their session.
As far as i know, there is no Desktop instances for session 0, whereas this session intended for NT services
But i might be wrong.
Check it with help of WinApi method
EnumDesktops
进行检查
祝您好运!
Good luck to you!
您必须将应用程序重写为服务.如果没有用户登录,无论如何都没有理由显示界面,那有什么用呢?
您无法绕开Session 0限制.现在,所有尝试显示UI的服务都将显示在备用桌面上,并且将向用户(如果有)通知该服务希望他们看到某些东西,并且可以切换到备用桌面也可以.
这是一项安全功能,是迫使开发人员以正确的方式执行操作并阻止我们编写显示UI的服务的中间步骤.
正确的方法是将您的应用程序编写为服务来完成工作.该服务还将公开一个接口,供用户应用程序连接以与该服务通信并向/从该服务发送/获取数据.
You have to rewrite the application as a service. If no user is logged in, there''s no reason to show an interface anyway, so what''s the point??
You cannot get around the Session 0 limitation. All services that try to show a UI will now be shown on an alternate desktop and the user, if any, will be notified that a service wants them to see something and if it would be OK to switch to the alternate desktop.
This is a security feature and an intermediate move to force developers to do things the correct way and stop us from writing services that show a UI.
The correct way to do this would have been to write your app as a service to do the work. The service would also expose an interface for a user application to connect to to communicate with the service and send/get data to/from it.
这篇关于在Windows Server 2008的Task Sheduler中使用UI运行应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!