我正在尝试使用<util:User Id="UpdateServiceAccountLogonAsService" UpdateIfExists="yes" CreateUser="no" Name="[SERVICEACCOUNTFULL]" LogonAsService="yes"/>
将logonAsService授予UI指定的用户。此util之前的属性值 IS UPDATED :用户在运行时获得处理。
我知道这是因为我可以给SERVICEACCOUNTFULL属性一个默认值“localhost \ defaultUserValue”并设置CreateUser =“yes”并且它将生成一个运行时消息框错误,该错误显示之后的原始值 >我的自定义操作已设置属性值。不确定为什么无法创建用户,但它显示正确的时间。如果我将属性默认值硬编码为动态设置它们(使用CreateUser="no"
),它就可以工作。
我作为同一组件的一部分的<ServiceInstall />
标记正确使用了属性的更新值,但<util:User />
不会。
请记住,我正在验证createUser步骤是在设置Property值的自定义操作程序之后发生的。但现在我会奇怪地提到,createUser动作执行位于自定义动作上方的日志中,该动作获取属性值并且Before="InstallFiles"
。
帮助?谢谢!
===========
嗨Rob,
不完全确定你需要看到什么,但我认为这些是相关的:
<Component Id="Service" Guid='*'>
<File Source='$(var.root)My Service.exe' />
<ServiceInstall Id="ServiceInstall"
Name="MyServer"
DisplayName="My Server"
Type="ownProcess"
Start="auto"
ErrorControl="normal"
Description="My Server Windows Service"
Interactive="no"
Account="[SERVICEACCOUNTFULL]"
Password="[SERVICEACCOUNTPASSWORD]" />
<ServiceControl Id="StopMyServer" Name="MyServer" Stop="both" Wait="yes" Remove="uninstall" />
<util:User Id="UpdateServiceAccountLogonAsService" UpdateIfExists="yes"
CreateUser="no" Name="[SERVICEACCOUNTFULL]" LogonAsService="yes"/>
</Component>
...
<Binary Id="ConfigBinary" SourceFile="$(var.....TargetDir)$(var.Configuration.TargetName).CA.exe" />
<Property Id="Net">net.exe</Property>
<CustomAction Id="NetStart" Property="Net" ExeCommand="START MyServer" Return="check" />
<Property Id="PerformNetStart" Value="0" />
<CustomAction Id='SetPerformNetStart' Property='PerformNetStart' Value='1' />
<CustomAction Id="RunConfiguration" BinaryKey="ConfigBinary" DllEntry="RunConfiguration" Execute="immediate" Return="check" />
<CustomAction Id='IsPrivileged' Error='You must be an admin to install this feature' />
<InstallExecuteSequence>
<Custom Action='IsPrivileged' Before='RunConfiguration'>
<![CDATA[Not Privileged AND &FeatureServer > 2 ]]>
</Custom>
<Custom Action="RunConfiguration" Before="InstallFiles">
<![CDATA[&FeatureServer > 2 AND Not Installed ]]>
</Custom>
<Custom Action="SetPerformNetStart" Before="InstallFiles">
<![CDATA[&FeatureServer > 2 AND Not Installed ]]>
</Custom>
<Custom Action="NetStart" After="InstallFinalize">
PerformNetStart = 1
</Custom>
</InstallExecuteSequence>
然后在C#中:
public static ActionResult RunConfiguration(Session session)
{
session["SERVICEACCOUNTFULL"] = "MyDomain\svcAccount";
session["SERVICEACCOUNTPASSWORD"] = "secret;
return ActionResult.Success;
}
以下是硬编码有效值运行的日志:
MSI (s) (F0:F8) [18:29:29:191]: Created Custom Action Server with PID 4796 (0x12BC).
MSI (s) (F0:CC) [18:29:29:211]: Running as a service.
MSI (s) (F0:CC) [18:29:29:213]: Hello, I'm your 32bit Impersonated custom action server.
MSI (s) (F0!48) [18:29:29:240]: PROPERTY CHANGE: Adding CreateUserRollback property. Its value is '**********'.
MSI (s) (F0!48) [18:29:29:243]: Doing action: CreateUserRollback
Action 18:29:29: CreateUserRollback.
Action start 18:29:29: CreateUserRollback.
CreateUserRollback:
Action ended 18:29:29: CreateUserRollback. Return value 1.
MSI (s) (F0!48) [18:29:29:247]: PROPERTY CHANGE: Adding CreateUser property. Its value is '**********'.
MSI (s) (F0!48) [18:29:29:247]: Doing action: CreateUser
Action 18:29:29: CreateUser.
Action start 18:29:29: CreateUser.
CreateUser:
Action ended 18:29:29: CreateUser. Return value 1.
Action ended 18:29:29: ConfigureUsers. Return value 1.
MSI (s) (F0:F0) [18:29:29:252]: Skipping action: IsPrivileged (condition is false)
MSI (s) (F0:F0) [18:29:29:252]: Doing action: RunConfiguration
Action 18:29:29: RunConfiguration.
Action start 18:29:29: RunConfiguration.
MSI (s) (F0:E0) [18:29:29:286]: Invoking remote custom action. DLL: C:\Windows\Installer\MSIC008.tmp, Entrypoint: RunConfiguration
SFXCA: Extracting custom action to temporary directory: C:\Users\Jason\AppData\Local\Temp\MSIC008.tmp-\
SFXCA: Binding to CLR version v4.0.30319
Calling custom action ...Configuration!...RunConfiguration
Begin RunConfiguration
Setting MSI values from RunConfiguration
MSI (s) (F0!48) [18:29:47:629]: PROPERTY CHANGE: Modifying RUNTIMECONNECTIONSTRING property. Its current value is 'DEFAULT'. Its new value: 'Data Source=.;Initial Catalog=DB;Integrated Security=True'.
MSI (s) (F0!48) [18:29:47:629]: PROPERTY CHANGE: Modifying SERVICEACCOUNTFULL property. Its current value is 'MyDomain\DEFAULTVALUE'. Its new value: 'MyDomain\svcAccount'.
...
Returning from RunConfiguration
它以向后顺序记录,这可以解释问题,但是当我在CreateUser =“yes”上创建CreateUser操作错误时,它会在Configuration自定义操作返回后显然发生几次节拍。但也许它排队了一些奇怪的方式,真正的执行顺序是问题 - 在这种情况下我仍然不知道如何控制该顺序。
这是您要诊断的好信息吗?
答案 0 :(得分:1)
问题是,设置RunConfiguration
元素使用的属性的自定义操作User
运行得太晚了。而不是在RunConfiguration
之前安排InstallFiles
而是在ConfigureUsers
之前安排行动。类似的东西:
<Custom Action="RunConfiguration" Before="ConfigureUsers">
<![CDATA[&FeatureServer > 2 AND Not Installed ]]>
</Custom>