简体   繁体   English

安装程序以管理员权限运行后如何在非管理员窗口中打开应用程序

[英]How to open the app in non-admin window after the installer run with Admin privileges

Background: The installation of our application requires Admin privileges. 背景:安装我们的应用程序需要管理员权限。 After the installer has finished we are calling the newly installed program from the installer, and it opens in an Admin window. 安装程序完成后,我们从安装程序中调用新安装的程序,该程序在“管理”窗口中打开。 (This is at least how it works on Windows) Then when we click on the icon to run the program, it opens another window (thus two instances of the app are running -- not a good thing.) (至少这是它在Windows上的工作方式)然后,当我们单击图标以运行程序时,它将打开另一个窗口(因此该应用程序的两个实例正在运行-不好。)

Is it possible run both the installer and the app from a batch file, so that only after the installer is closed, the app opens in an non-admin window? 是否可以从批处理文件运行安装程序和应用程序,以便仅在关闭安装程序后,该应用程序才能在非管理员窗口中打开? (In our app the installer asks for the admin privileges, so the batch file should not do that.) (在我们的应用程序中,安装程序会要求管理员权限,因此批处理文件不应这样做。)

I tried experimenting with this using "Everything.exe" (an excellent app that requires admin privileges). 我尝试使用“ Everything.exe”(需要管理员权限的出色应用)进行实验。

REM Test batchfile for opening two apps
"C:\Program Files (x86)\Everything\Everything.exe"
Notepad.exe

unfortunately as soon as Admin privileges are granted to "Everything.exe", Everything loads in the Admin window, and the Notepad loads in the non-admin window. 不幸的是,一旦授予“ Everything.exe”管理员权限,“一切”就会加载到“管理员”窗口中,而记事本也会加载到非管理员窗口中。

Is there a way to open the app in non-admin windows after the installer exits?" 安装程序退出后,是否可以在非管理窗口中打开应用程序?”

You should be able to use MSI (Windows Installer) to install the product with "elevated rights" as opposed to "administrator rights". 您应该能够使用MSI(Windows Installer)安装具有“提升的权限”而不是“管理员权限”的产品。 Windows Installer features a built-in mechanism to impersonate an administrator for the installation transaction when the setup is launched in a regular users login session (there are some policy settings that have to be enabled). Windows Installer具有内置机制,可以在常规用户登录会话中启动安装程序时模拟安装事务的管理员(必须启用某些策略设置)。

It should also be possible to run an MSI with administrator rights and launch an application from the final setup dialog with regular user rights (perhaps not if launched from an admin rights cmd.exe - not sure, it should launch the msi by right click run as admin) This is possible because the MSI GUI never runs with elevated privileges - it is the installation transaction launched by the GUI that has elevated rights. 还应该可以运行具有管理员权限的MSI,并从具有常规用户权限的最终设置对话框中启动应用程序 (也许不是从管理员权限cmd.exe启动的情况-不确定,应通过右键单击运行来启动msi。作为管理员),这是可能的,因为MSI GUI永远不会以提升的特权运行-这是GUI提升的权限启动的安装事​​务。 Once the transaction is complete, the control returns to the GUI running with regular rights. 事务完成后,控件将返回到具有常规权限的GUI。 From here you can launch the app via a button click. 在这里,您可以通过单击按钮启动应用程序。

This description is somewhat simplified, I'll leave it at that since MSI might not be an option for you. 此描述有些简化,我将不再赘述,因为MSI可能不是您的选择。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM