Untitled
unknown
csharp
2 years ago
1.2 kB
6
Indexable
using System; using System.Diagnostics; using System.Text.RegularExpressions; namespace ConsoleApp { class Program { static void Main(string[] args) { var process = new Process { StartInfo = new ProcessStartInfo { FileName = "powercfg", Arguments = "/GETACTIVESCHEME", RedirectStandardOutput = true, UseShellExecute = false, CreateNoWindow = true, Verb = "runas", // UAC prompt } }; process.Start(); string output = process.StandardOutput.ReadToEnd(); process.WaitForExit(); var match = Regex.Match(output, @"GUID: (.*) \("); if (match.Success) { string guid = match.Groups[1].Value; Console.WriteLine($"Current power scheme GUID: {guid}"); } else { Console.WriteLine("Could not find power scheme GUID"); } } } }
Editor is loading...