Visual Studio安装项目:以当前用户身份而不是系统帐户身份运行CustomActions/process [英] Visual Studio setup project: run CustomActions/process as current user not system account
问题描述
我正在Visual Studio 2010中使用一个安装项目来安装C#Outlook外接程序(Office 2010/2013)和其他独立工具.在安装过程中,我将杀死所有Outlook实例,然后再重新启动Outlook实例.
I'm using a setup project in visual studio 2010 for a c# outlook add-in (Office 2010/2013) and an other standalone tool. During the installation I kill all instances of outlook, afterwards I want to restart an instance of outlook.
在我的外接程序项目中,我添加了一个安装程序类,并在我执行的地方添加了一个InstallEventHandler(AfterInstallEventHandler)
In my addin project I added an installerclass and added an InstallEventHandler(AfterInstallEventHandler) where I execute
Process.Start("Outlook");
虽然同一命令只是在另一个已编译的类中打开Outlook,但是在安装程序Outlook的上下文中会在配置文件创建助手中打开
While the same command simply opens Outlook in an other compiled class, in the context of the installer outlook opens in the profile creation assistant.
我还试图在提交后将所说的工作编译后的exe作为用户定义的操作运行,但是出现相同的问题.
I also tried to run said working compiled exe as an user defined action after the commit, but same problem occurs.
任何解决方案或解释将不胜感激.
Any solution or explanation would be appreciated.
推荐答案
解决方案:
安装以SYSTEM帐户运行.因此,创建的过程也以该帐户运行,而不是以当前登录的用户身份运行.
The installation runs in the SYSTEM account. Therefor the created process is also run in said account, not as the currently logged in user.
我创建了一个附加项目(InstallHelper),其中包括
I created an additional project (InstallHelper), which includes the
Process.Start("Outlook");
我在安装项目中将InstallHelper添加为Commit上的CustomAction,并在CustomAction的属性中将InstallerClass更改为False.然后,我将WiRunSql.vbs复制到项目文件夹,并将PostBuildEvent添加到安装项目:
I added the InstallHelper as CustomAction on Commit in my setup project and changed InstallerClass to False in the properties of the CustomAction. Then I copied WiRunSql.vbs to the project folder and added an PostBuildEvent to the setup project:
@echo off
cscript //nologo "$(ProjectDir)WiRunSql.vbs" "$(BuiltOutputPath)" "UPDATE CustomAction SET Type=1554 WHERE Type=3602"
3602:
- 0x800(msidbCustomActionTypeNoImpersonate)
- 0x400(msidbCustomActionTypeInScript)
- 0x200(msidbCustomActionTypeCommit)
- 0x12(自定义操作类型18:exe)
1554:
- 0x400(msidbCustomActionTypeInScript)
- 0x200(msidbCustomActionTypeCommit)
- 0x12(自定义操作类型18:exe)
请参阅: msdn:自定义操作脚本内执行选项
类型更改删除了msidbCustomActionTypeNoImpersonate(0x00000800)的位,因此InstallHelper和创建的进程以登录用户身份而不是SYSTEM身份运行.
The Type-change removed the bit for msidbCustomActionTypeNoImpersonate (0x00000800), so the InstallHelper and the created process are run as the logged in user, not as SYSTEM.
或者,可以通过在orca中打开msi来进行这些更改(每次构建后都需要重复,因此我更喜欢脚本化的更改).
Alternatively those changes are possible via opening the msi in orca (has to be repeated after each build, so I prefer the scripted change).
这篇关于Visual Studio安装项目:以当前用户身份而不是系统帐户身份运行CustomActions/process的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!