mirror of
https://github.com/rustdesk/rustdesk.git
synced 2024-12-22 08:47:51 +08:00
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;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|