.net windows服务
问题描述:
大家好
我用C#制作了一个Windows服务。现在我有一种情况,我需要
调用带有一些UI的exe。假设运行此服务的计算机
将始终登录,任何人都可以请给我一个示例代码来
从.net中的Windows服务调用exe。 />
我尝试了一些我在网上找到的方法,但他们似乎在后台调用
的东西实际上不起作用。
任何帮助非常感谢。
提前致谢。
祝你好运,
Nitesh Gupta
Hi All
I made a windows service in C#. Now I have a situation where I need to
invoke an exe with some UI. Assuming that the computer running this service
will always be logged in, can anyone please provide me a sample code to
invoke an exe from windows service in .net.
I tried a few methods that I found on the net but they seem to invoke
something in the background which actually does not work.
Any help is much appreciated.
Thanks in advance.
Best regards,
Nitesh Gupta
答
你已经尝试过Process类了?也许您只需要将ServiceController.ServiceType更改为256(InteractiveProcess)?
You already tried the Process class? Perhaps you merely need to change
the ServiceController.ServiceType to 256 (InteractiveProcess)?
感谢您回复KJ。
是的,我使用了Process类..
我这样做了:
System.Diagnostics.Process p = new System。 Diagnostics.Process();
p.StartInfo.FileName =" notepad.exe" ;; //我有一个不同的程序要运行
bool x = p.Start();
你能不能给我一个示例代码片段给我
你提到的ServiceController.ServiceType。一点指导/提示
也可以帮助我让我开始走正确的道路。我不确定
在哪里设置你提到的那个属性。
谢谢,
Nitesh
KJ < N _ ********** @ mail.com>在消息中写道
news:11 ********************** @ f14g2000cwb.googlegr oups.com ...
Thanks for the reply KJ.
Yes, I used Process class..
I did this::
System.Diagnostics.Process p = new System.Diagnostics.Process();
p.StartInfo.FileName="notepad.exe"; // I have a different program to be run
bool x=p.Start();
Could you please give me a sample code snippet for the
ServiceController.ServiceType that you mentioned. A little guideline/hint
might also help me to get me started on the right path. I am not sure where
to set that property you mentioned.
Thanks,
Nitesh
"KJ" <n_**********@mail.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
您已经尝试过Process类了吗?也许您只需要将ServiceController.ServiceType更改为256(InteractiveProcess)?
You already tried the Process class? Perhaps you merely need to change
the ServiceController.ServiceType to 256 (InteractiveProcess)?
如果我检查选项,我能够实现此目的允许服务互动
与桌面来自MMC的服务属性。不确定如何以编程方式设置此
选项。
I am able to achieve this if I check the option "Allow service to interact
with desktop" in service properties from MMC. Not sure how to set this
option programmatically.