Made a command that can be used to run other processes.
This commit is contained in:
parent
daae786bec
commit
a2b9daa107
@ -255,6 +255,13 @@ public static class BaseModule
|
||||
[Command("echo")]
|
||||
public static void Echo(string msg) => Write(msg);
|
||||
|
||||
[Command("exit")]
|
||||
[Command("quit")]
|
||||
public static void QuitShell(int code = 0)
|
||||
{
|
||||
Environment.Exit(code);
|
||||
}
|
||||
|
||||
[Command("explorer")]
|
||||
public static void OpenExplorer(string path = ".") => Process.Start("explorer.exe", Path.GetFullPath(path));
|
||||
|
||||
@ -318,6 +325,23 @@ public static class BaseModule
|
||||
Write(reader.ReadToEnd());
|
||||
}
|
||||
|
||||
[Command("run")]
|
||||
[CanCancel(false)]
|
||||
public static void RunProcess(string name, string args = "")
|
||||
{
|
||||
Process? run = Process.Start(new ProcessStartInfo()
|
||||
{
|
||||
Arguments = args,
|
||||
CreateNoWindow = false,
|
||||
ErrorDialog = true,
|
||||
FileName = name
|
||||
});
|
||||
|
||||
if (run is null) throw new($"Error starting the process \"{name}\"");
|
||||
|
||||
run.WaitForExit();
|
||||
}
|
||||
|
||||
[Command("sleep")]
|
||||
public static void WaitTime(int timeMs) => Thread.Sleep(timeMs);
|
||||
|
||||
@ -370,13 +394,6 @@ public static class BaseModule
|
||||
});
|
||||
}
|
||||
|
||||
[Command("exit")]
|
||||
[Command("quit")]
|
||||
public static void QuitShell(int code = 0)
|
||||
{
|
||||
Environment.Exit(code);
|
||||
}
|
||||
|
||||
[Command("undo")]
|
||||
public static void UndoCommand(int amount = 1)
|
||||
{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user