简体   繁体   English

如何在VS安装程序项目中使用非托管DLL,但又不需要用户具有管理员权限?

[英]How to use an unmanaged DLL in VS installer project, but without the user needing admin rights?

I'm creating an installer for a C# project. 我正在为C#项目创建安装程序。 It requires an unmanaged 3rd party C++ dll to connect to a hardware device. 它需要不受管理的第三方C ++ dll才能连接到硬件设备。 When I run the project from the debugger, or when I right click -> Run as Administrator on the installed program, everything works normally. 当我从调试器运行项目时,或在已安装的程序上右键单击->以管理员身份运行时,一切正常。 However if I don't run this as administrator in some fashion, it crashes. 但是,如果我不以某种管理员身份运行它,它将崩溃。 So how do I set up the installer to not need admin rights to run? 那么,如何将安装程序设置为无需管理员权限即可运行? I know I can set the requestedExecutionLevel in the app.manifest to requireAdministrator , but I don't want the UAC prompt every time, and I'm not sure the end user's machines will be able to run anything as admin. 我知道我可以设置requestedExecutionLevel在app.manifest到requireAdministrator ,但我不希望UAC提示每一次,我不知道最终用户的机器将能够运行任何东西作为管理员。

My current workaround is to just install it directly to the C:/, but I'd like to install it to the same Program Files directory all the other apps are installed to which don't have this setback. 我当前的解决方法是将其直接安装到C:/,但是我想将其安装到相同的Program Files目录中,所有其他安装的应用程序都没有此挫折。

Limited users can't circumvent security restrictions just because they are running an install. 受限制的用户不能仅仅因为他们正在运行安装来规避安全性限制。 Writing to the ProgramFiles folder requires elevation (as do perhaps some other things the install does) so there is no choice other than elevating the install - and it will show a UAC elevation prompt. 写入ProgramFiles文件夹需要提升权限(安装可能还会做其他事情),因此除了提升安装之外别无选择-它将显示UAC提升提示。 You haven't said what tool you're using to build your MSI, but an MSI doesn't use a manifest and (to use WiX as an example) elevation uses the Package InstallPrivileges element. 您没有说过要使用什么工具来构建MSI,但是MSI不使用清单,并且(以WiX为例)高程使用Package InstallPrivileges元素。

The user doesn't NEED to be admin because the UAC prompt will allow an administrator to type their credentials "over the shoulder" for the install to work, if that turns out to be possible. 用户不需要成为管理员,因为如果可能的话,UAC提示符将允许管理员“凭空”键入其凭据以使安装正常进行。 There are also managed deployment options in corporate-type GPO install where the user doesn't need to be elevated. 公司类型的GPO安装中还有托管部署选项,不需要提升用户。

Having the MSI call your code requires creating a custom action that the install will call - it has a required calling convention. 使用MSI调用您的代码需要创建安装将调用的自定义操作-它具有必需的调用约定。 Then you can call from that into your 3rd party C++ Dll. 然后,您可以从中调用第三方C ++ Dll。 Without knowing more about the call you want to make it's difficult to add any more information. 如果不了解有关您要拨打的电话的信息,则很难添加更多信息。 Is the call early in the install (from the UI maybe)? 呼叫是否在安装的早期(可能是从UI)? After the install? 安装后? Is it a condition of the install? 这是安装的条件吗? Could it be done as a configuration check in the app after the install? 安装后可以作为应用程序中的配置检查来完成吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在.net项目中使用非托管dll? - How to use unmanaged dll in .net project? 使用没有管理员权限的 IIS 管理器 - Use IIS Manager without Admin Rights Visual Studio 安装项目:在没有管理员权限的情况下运行 msi 安装程序 - Visual Studio Setup Project: Run the msi installer without administrator rights 如何将非托管dll添加到C#项目 - How to add unmanaged dll to c# project 如何在不需要管理员权限的情况下访问Microsoft Graph API中已登录用户的组? - How can I access the signed in user's groups in Microsoft's Graph API without needing admin priviledges? 几个C#项目如何在没有繁琐的手动复制的情况下使用非托管DLL? - How can several C# Projects use an unmanaged DLL, without tedious manual copying? 从没有管理员权限的用户应用程序访问全局互斥锁/信号灯 - acces global mutex/semaphore from user application without admin rights 如何将非托管C ++ DLL添加到Silverlight 5项目中 - How to add unmanaged C++ dll into a Silverlight 5 project 如何在C#中没有管理员权限的情况下重新启动IIS - How To Restart IIS without Admin Rights in C# 如何在没有管理员权限的情况下发布并连接到我自己的WCF终结点 - How to publish and connect to my own WCF endpoint without Admin rights
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM