LinuxProcessUtility.cs 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. using System.Diagnostics;
  2. using System.Net;
  3. using System.Security;
  4. using PixiEditor.OperatingSystem;
  5. namespace PixiEditor.Linux;
  6. public class LinuxProcessUtility : IProcessUtility
  7. {
  8. public Process RunAsAdmin(string path)
  9. {
  10. throw new NotImplementedException("Running as admin is not supported on Linux");
  11. }
  12. public Process RunAsAdmin(string path, bool createWindow)
  13. {
  14. throw new NotImplementedException("Running as admin is not supported on Linux");
  15. }
  16. public bool IsRunningAsAdministrator()
  17. {
  18. return Environment.IsPrivilegedProcess;
  19. }
  20. public Process ShellExecute(string toExecute)
  21. {
  22. Process process = new Process();
  23. process.StartInfo.FileName = toExecute;
  24. process.StartInfo.UseShellExecute = true;
  25. process.Start();
  26. return process;
  27. }
  28. public Process ShellExecute(string toExecute, string args)
  29. {
  30. Process process = new Process();
  31. process.StartInfo.FileName = toExecute;
  32. process.StartInfo.Arguments = args;
  33. process.StartInfo.UseShellExecute = true;
  34. process.Start();
  35. return process;
  36. }
  37. public Process Execute(string path, string args)
  38. {
  39. Process process = new Process();
  40. process.StartInfo.FileName = path;
  41. process.StartInfo.Arguments = args;
  42. process.StartInfo.UseShellExecute = false;
  43. process.Start();
  44. return process;
  45. }
  46. }