c# msi中加入驱动_使用C#安装Msi文件

Solutions2

If the MSI requires admin rights to install then it will ask for elevation in a UI install. Your /q is failing because a silent install is really silent and will not prompt for elevation. Note that limited users are not allowed to break security rules simply because they are doing an install.

So in that situation your launching process would need to be elevated, either by running as administrator or giving it a requiresAdministrator manifest so it asks for elevation.

When you fire off the install you need to make sure that your elevated state is used to fire off the install. The simplest way to guarantee this is to just call (p/invoke to...) MsiInstallProduct () directly from your code. The issue with Process.Start is that by default ProcessStartInfo.UseShellExecute is true and your elevated state (if you have one) will not be used to start the install. When the install is launched it needs to be a CreateProcess type of execution rather than a ShellExecute type so that your elevated credentials are used.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值