如何让当前进程在以后启动应用程序时使用
How to get the current process to use later to start an application
我已经使用自定义 WPF UI 构建了一个 WIX 项目,该项目必须 运行 具有提升的权限。在 install/update 之后,我想启动我的应用程序,但我不希望应用程序以提升的权限启动。
目前我正在做以下事情
在 "Protected Overrides Sub Run()" 中,我执行以下操作
Dim m_LowProcess As Process = Process.GetCurrentProcess
然后一旦安装程序完成我运行下面的代码
Dim procStartInfo As New ProcessStartInfo
With procStartInfo
.FileName = fInfo.FullName
.WindowStyle = ProcessWindowStyle.Normal
End With
m_LowProcess.StartInfo = procStartInfo
m_LowProcess.Start()
我检查了进程 ID 和句柄属性,它们是相同的。但是我的程序在安装后仍然 运行 具有不同的权限。
我哪里做错了,或者这永远不会奏效?
我知道of this forum question which solves the problem other ways.
我不确定你的代码在做什么,但我相信正确的方法就像 ProcessStartinfo 文档中的这个例子:
只需通过指定可执行文件的路径并确保 UseShellExecute 为真来启动已安装的应用程序,以便进程启动的行为类似于资源管理器 运行(没有特权继承)。如果您不知道可执行文件的安装位置,那么向 MsiGetComponentPath 传递其组件 ID 和产品的产品代码的 p/invoke 将告诉您:
https://msdn.microsoft.com/en-us/library/aa370112(v=vs.85).aspx
我已经使用自定义 WPF UI 构建了一个 WIX 项目,该项目必须 运行 具有提升的权限。在 install/update 之后,我想启动我的应用程序,但我不希望应用程序以提升的权限启动。
目前我正在做以下事情
在 "Protected Overrides Sub Run()" 中,我执行以下操作
Dim m_LowProcess As Process = Process.GetCurrentProcess
然后一旦安装程序完成我运行下面的代码
Dim procStartInfo As New ProcessStartInfo
With procStartInfo
.FileName = fInfo.FullName
.WindowStyle = ProcessWindowStyle.Normal
End With
m_LowProcess.StartInfo = procStartInfo
m_LowProcess.Start()
我检查了进程 ID 和句柄属性,它们是相同的。但是我的程序在安装后仍然 运行 具有不同的权限。
我哪里做错了,或者这永远不会奏效?
我知道of this forum question which solves the problem other ways.
我不确定你的代码在做什么,但我相信正确的方法就像 ProcessStartinfo 文档中的这个例子:
只需通过指定可执行文件的路径并确保 UseShellExecute 为真来启动已安装的应用程序,以便进程启动的行为类似于资源管理器 运行(没有特权继承)。如果您不知道可执行文件的安装位置,那么向 MsiGetComponentPath 传递其组件 ID 和产品的产品代码的 p/invoke 将告诉您: https://msdn.microsoft.com/en-us/library/aa370112(v=vs.85).aspx