mirror of
https://github.com/theitaliandeveloper/Perfect11.git
synced 2025-12-06 09:02:03 +00:00
27 lines
784 B
C#
27 lines
784 B
C#
using System.Diagnostics;
|
|
|
|
namespace Perfect11.Library
|
|
{
|
|
public class PowerShell
|
|
{
|
|
public string Execute(string command)
|
|
{
|
|
ProcessStartInfo psi = new ProcessStartInfo
|
|
{
|
|
FileName = "powershell.exe",
|
|
Arguments = $"-NoProfile -ExecutionPolicy Bypass -Command \"{command}\"",
|
|
RedirectStandardOutput = true,
|
|
RedirectStandardError = true,
|
|
UseShellExecute = false,
|
|
CreateNoWindow = true
|
|
};
|
|
using (Process process = Process.Start(psi))
|
|
{
|
|
string output = process.StandardOutput.ReadToEnd();
|
|
process.WaitForExit();
|
|
return output;
|
|
}
|
|
}
|
|
}
|
|
}
|