[英]How to run exe file after installation servise with WIX.sharp (My objective - create msi for service)?
我使用WIX.sharp創建msi。 請幫助我:安裝服務后如何運行exe文件? 現在它導致錯誤(當我使用我的msi時)。 我的應用程序啟動了服務的初始化配置文件。 現在看起來像這樣:
project.Binaries = new[]
{
new Binary(new Id("StartAdmin"), "xxx.exe")
};
project.Actions = new WixSharp.Action[]
{
new BinaryFileAction("StartAdmin", "Executing ...", Return.check, When.After, Step.InstallExecute, Condition.NOT_Installed)
{
Execute = Execute.commit
}
謝謝。 我按照我的要求做了。 我想分享結果。
using Microsoft.Deployment.WindowsInstaller;
...
var project = new Project("Application Name", GetAllEntities(releaseDir, parentDir, out service));
...
private static Dir GetDirs(string releaseDir, string parentDir, out File service)
{
var docDir = System.IO.Path.GetFullPath(System.IO.Path.Combine(parentDir, @"pub\\doc\\"));
return new Dir(new Id("SERVICEDIR"), @"%ProgramFiles%\Application\",
new Dir(new Id("INSTALLSERVICEDIR"), "App name",
new Dir(new Id("BINSERVICEDIR"), "bin",
...
new File(string.Format("{0}{1}", releaseDir, "Admin.exe")),
...
project.AddAction(new ManagedAction(CustomActions.MyAction, Return.check, When.After, Step.InstallFinalize, Condition.NOT_Installed));
...
public class CustomActions
{
[CustomAction]
public static ActionResult MyAction(Session session)
{
System.Diagnostics.Process process = new System.Diagnostics.Process();
process.StartInfo.FileName = string.Format("{0}\\Admin.exe", session["BINSERVICEDIR"]);
process.StartInfo.Arguments = "-n";
process.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal;
process.Start();
process.WaitForExit();
return ActionResult.Success;
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.