* Feat. msi Signed-off-by: fufesou <shuanglongchen@yeah.net> * remove ununsed file Signed-off-by: fufesou <shuanglongchen@yeah.net> --------- Signed-off-by: fufesou <shuanglongchen@yeah.net>
57 lines
1.5 KiB
C#
57 lines
1.5 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Diagnostics;
|
|
using System.Runtime.InteropServices;
|
|
using WixToolset.Dtf.WindowsInstaller;
|
|
|
|
namespace CustomActions
|
|
{
|
|
public class CustomActions
|
|
{
|
|
[CustomAction]
|
|
public static ActionResult CustomActionHello(Session session)
|
|
{
|
|
try
|
|
{
|
|
session.Log("================= Example CustomAction Hello");
|
|
return ActionResult.Success;
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
session.Log("An error occurred: " + e.Message);
|
|
return ActionResult.Failure;
|
|
}
|
|
}
|
|
|
|
[CustomAction]
|
|
public static ActionResult RunCommandAsSystem(Session session)
|
|
{
|
|
try
|
|
{
|
|
ProcessStartInfo psi = new ProcessStartInfo
|
|
{
|
|
|
|
FileName = "cmd.exe",
|
|
Arguments = "/c " + session["CMD"],
|
|
UseShellExecute = false,
|
|
WindowStyle = ProcessWindowStyle.Hidden,
|
|
Verb = "runas"
|
|
};
|
|
|
|
using (Process process = Process.Start(psi))
|
|
{
|
|
process.WaitForExit();
|
|
}
|
|
|
|
return ActionResult.Success;
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
session.Log("An error occurred: " + e.Message);
|
|
return ActionResult.Failure;
|
|
}
|
|
}
|
|
}
|
|
}
|