我正在为IIS网站创建Wix安装程序,可以在UI中选择网站、应用程序池和选择虚拟目录。问题是:我成功地创建了安装程序,它与关闭UAC一起工作,但是UAC设置为max。我从MSI日志中得到错误:
MSI (c) (A0:C8) 16:41:21:692:调用远程自定义操作。DLL: C:\Users\kovac\AppData\Local\Temp\MSI1AEF.tmp,入口点: EnumerateIISWebSitesAndAppPools MSI (c) (A0:CC) 16:41:21:692:隐形启用。MSI (c) (A0:CC) 16:41:21:692:尝试在调用Server (c) (A0:CC) 16:41:21:692:连接到CA接口的服务之前启用所有禁用的特权。SFXCA:将自定义操作提取到临时目录: C:\Users\kovac\AppData\Local\Temp\MSI1AEF.tmp-\ SFXCA:绑定到CLR v4.0.30319调用自定义操作WebAppInstallCustomActions!WebAppInstallCustomActions.CustomActions.EnumerateIISWebSitesAndAppPools EnumerateIISWebSitesAndAppPools: Begin EnumerateIISWebSitesAndAppPools :试图在没有管理员权限的情况下运行CustomAction EnumerateIISWebSitesAndAppPools返回实际错误代码1603 (注意,如果在沙箱内进行转换,这可能不会100%准确)操作结束于16:41:23: EnumerateIISWebSitesAndAppPools。返回值3.msi (c) (A0:B0) 16:41:23:878:操作: FatalError操作16:41:23: FatalError。
我试着跟随文章-我刚刚理解的是,我应该运行我的自定义操作与Impersonate=“否”,所以我做了,但没有成功的附加信息:没有问从UAC是否可以运行的自定义操作,它只是结束安装程序.
<CustomAction Id="EnumerateIISWebSitesAndAppPools"
BinaryKey="WebAppCA"
DllEntry="EnumerateIISWebSitesAndAppPools"
Execute="immediate"
Return="check" Impersonate="no" /> 另外,我在某个地方读到,操作需要作为被删除的操作来运行--但在这种情况下是不可能的--因为我需要在安装之前为用户列出网站列表。
我的问题是如何使用完全正确的方式运行自定义操作--在UAC上,特别是UAC是如何在运行CA时应用管理权限的?感谢你的帮助或建议.由于我不知道重要性和问题域,我宁愿附加用C#编写的自定义操作脚本:
/// <summary>
/// Adds the II7 web sites and the application pool names to the
/// ComboBox table in the MSI file.
/// </summary>
/// <param name="session">
/// The installer session.
/// </param>
/// <returnenter code heres>
/// Always returns ActionResult.Success, otherwise rethrows the error
/// encountered.
/// </returns>
/// <exception cref="ArgumentNullException">
/// Thrown if the <paramref name="session"/> parameter is null.
/// </exception>
[CustomAction]
public static ActionResult EnumerateIISWebSitesAndAppPools(
Session session)
{
Debugger.Launch();
if (null == session)
{
throw new ArgumentNullException("session");
}
session.Log("EnumerateIISWebSitesAndAppPools: Begin");
// Check if running with admin rights and if not, log a message to
// let them know why it's failing.
if (false == HasAdminRights())
{
session.Log("EnumerateIISWebSitesAndAppPools: " +
"ATTEMPTING TO RUN WITHOUT ADMIN RIGHTS");
return ActionResult.Failure;
}
session.Log("EnumerateIISWebSitesAndAppPools: " +
"Getting the IIS 7 management object");
ActionResult result;
using (ServerManager iisManager = new ServerManager())
{
result = EnumSitesIntoComboBox(session, iisManager);
if (ActionResult.Success == result)
{
result = EnumAppPoolsIntoComboBox(session, iisManager);
}
}
session.Log("EnumerateIISWebSitesAndAppPools: End");
return result;
}私有静态ActionResult EnumSitesIntoComboBox(会话,ServerManager iisManager) { try { // Debugger.Break();session.Log("EnumSites: Begin");
// Grab the combo box but make sure I'm getting only the one
// from WebAppInstallDlg.
View view = session.Database.OpenView(
"SELECT * FROM ComboBox WHERE ComboBox.Property='WEBSITE_NAME'");
view.Execute();
Int32 index = 1;
session.Log("EnumSites: Enumerating the sites");
foreach (Site site in iisManager.Sites)
{
// Create a record for this web site. All I care about is
// the name so use it for fields three and four.
session.Log("EnumSites: Processing site: {0}", site.Name);
Record record = session.Database.CreateRecord(4);
record.SetString(1, "WEBSITE_NAME");
record.SetInteger(2, index);
record.SetString(3, site.Name);
record.SetString(4, site.Name);
session.Log("EnumSites: Adding record");
view.Modify(ViewModifyMode.InsertTemporary, record);
index++;
}
view.Close();
session.Log("EnumSites: End");
}
catch (Exception ex)
{
session.Log("EnumSites: exception: {0}", ex.Message);
throw;
}
return ActionResult.Success;
}
static bool HasAdminRights()
{
WindowsIdentity identity = WindowsIdentity.GetCurrent();
WindowsPrincipal principal = new WindowsPrincipal(identity);
return principal.IsInRole(WindowsBuiltInRole.Administrator);
}发布于 2015-01-20 16:41:02
UI序列中的所有ca都必须是即时的。模拟不适用于直接CA。最佳实践是UI不被提升,所以最佳实践说CA不应该要求提升私隐。如果没有办法解决这个问题,您将需要使用引导程序来调用MSI并在调用它之前提升它。
发布于 2015-01-20 21:10:38
您可以使用对话框收集UI模式中的数据,该对话框将设置一组属性,然后在没有UI的延迟自定义操作中使用这些属性。如果将包InstallPrivileges提升,则延迟CA以您所需的权限运行。如果您真的想在您编写的代码中完成所有这些操作,那么在安装之后使用一个海拔清单运行它,以配置网站。
或者,只需查看WiX IIS扩展是否可以满足您的需要。或者这个:http://www.codeproject.com/Articles/115036/Creating-WIX-Installer-for-ASP-NET-Web-Application
这一切都做了这么多次以前,它是不值得再一次发明。
https://stackoverflow.com/questions/28049955
复制相似问题