安装msi后启动exe,但使用当前用户权限 [英] Start exe after msi install but using current user privileges

查看:167
本文介绍了安装msi后启动exe,但使用当前用户权限的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Visual Studio 2008生成MSI安装软件包.在安装过程中,我有许多自定义操作.在OnAfterInstall自定义操作中,我尝试启动一个由安装程序部署的exe.该exe可以正常运行,但可以在NT AUTHORITY \ SYSTEM的安全上下文中运行(即在授予Windows Installer进程的提升特权下).我实际上需要exe在首先开始安装的当前登录用户的安全上下文中运行.有谁知道如何启动exe,以便它在这种简化"的上下文中运行.我真的想避免尽可能地向用户询问他们的登录凭据.

I am using Visual Studio 2008 to build an MSI install package. Within the install I have numerous custom actions. Within the OnAfterInstall custom action I attempt to start an exe which is deployed by the install. The exe starts ok, but runs within a security context of NT AUTHORITY\SYSTEM (i.e. under the elevated privileges granted to the Windows Installer process). I actually need the exe to run in the security context of the currently logged-on user who started the install in the first place. Does anyone know how to start the exe so it runs in this 'reduced' context. I really want to avoid having to ask the user for their login credentials if possible.

推荐答案

您需要使用远程桌面服务API:

You need to use Remote Desktop Services API: http://msdn.microsoft.com/en-us/library/aa383464%28v=VS.85%29.aspx . It is available starting from WinXP.

此API允许您在任何已登录用户帐户的上下文中运行应用程序.您需要作为系统运行才能使用它.你是. 例如,您可以使用WTSEnumerateSessions枚举会话,然后通过WTSQueryUserToken获取用户令牌并使用此令牌运行应用程序.

This API allows you to run your application in context of any logged in user account. You need to be running as a SYSTEM to be able to use it. And you are. For instance you may enumerate sessions using WTSEnumerateSessions, then take user token by WTSQueryUserToken and run application using this token.

这篇关于安装msi后启动exe,但使用当前用户权限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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