Starting a windows application from a windows service

懵懂的女人 提交于 2021-02-07 12:10:18

问题


I am trying to start a windows application from a windows Service using the below code

Process.Start(@"filename.exe");

In windows 7 I receive a popup that says, "A program running on this computer is trying to display a message"


回答1:


have a look at the following link:

http://www.codeproject.com/KB/vista-security/SubvertingVistaUAC.aspx




回答2:


You cannot start an interactive application from a Windows Service. This was changed in Windows Vista and 7.

Some other advice was given in this Stack Overflow answer on the same subject.

When I've needed to do this, I had to change my Windows Service to a Console Application, and invoked it in that manner.




回答3:


A work-around I found for this issue was to use the windows task scheduler. You can schedule the application to run some amount of seconds later by creating a batch file.




回答4:


At my previous company we had this issue and we wrote a console app that ran in the sys tray and acted as a bridge from the service to the desktop. Basically via remoting (I'd use WCF now of course) we let the service request that the console app start up another application.



来源:https://stackoverflow.com/questions/4398694/starting-a-windows-application-from-a-windows-service

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!