我的 exe 本身运行良好,但被服务加载时什么也不做 [英] My exe runs fine by itself, but does nothing when loaded by a service

查看:21
本文介绍了我的 exe 本身运行良好,但被服务加载时什么也不做的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

托盘图标的简单exe,独立工作正常

Simple exe for a tray icon, that works fine independently

我使用 Windows 服务调用它,它似乎运行(在任务管理器中)但它似乎不执行任何代码.即没有托盘图标等

I call it using a windows service, and it seems to run(in task manager) but it dosnt seem to exec any code. ie no tray icon etc.

推荐答案

在 Vista 和 Windows 2008 上,服务在与用户不同的会话中运行——服务运行的任何 EXE 都将在与服务相同的会话中运行.在 Vista 之前,您需要选中允许服务与桌面交互"框,否则同样适用.

On Vista and Windows 2008, services run in a different session than the user -- any EXE that a service runs will run in the same session as the service. Before Vista, you need to check the "Allow Service to interact with desktop" box, otherwise the same thing applies.

这意味着您的托盘图标 EXE 无法与用户的桌面交互.您需要查看使用 CreateProcessAsUser 在正确的会话中运行 EXE.

This means that your tray icon EXE isn't able to interact with the user's desktop. You need to look at using CreateProcessAsUser to run the EXE in the correct session.

这篇博文面向使用 ConfigMgr OS Deployment 的人,但它包含在另一个会话中运行进程所需的步骤的一个很好的列表.您需要采取一些不明显的步骤,否则事情就会以奇怪的方式失败.

This blog post is aimed at people using ConfigMgr OS Deployment, but it contains a good list of the steps needed to run a process in another session. There are some non-obvious steps that you need to take or things fail in weird ways.

这篇关于我的 exe 本身运行良好,但被服务加载时什么也不做的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆