Files
ucvl-zonghengjia-open-source/windows/SystemPowerShell.cs
2026-10-11 23:23:20 +00:00

23 lines
857 B
C#

using System.Diagnostics;
using System.Text;
namespace UCVL.VPNPlus;
// Fixed executable and working directory: never inherit NSIS's temporary payload.
internal static class SystemPowerShell
{
internal static ProcessStartInfo CreateStartInfo(string script) => new()
{
FileName = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.System),
"WindowsPowerShell", "v1.0", "powershell.exe"),
WorkingDirectory = Environment.GetFolderPath(Environment.SpecialFolder.System),
Arguments = "-NoProfile -NonInteractive -EncodedCommand "
+ Convert.ToBase64String(Encoding.Unicode.GetBytes(script)),
UseShellExecute = false,
CreateNoWindow = true,
WindowStyle = ProcessWindowStyle.Hidden,
RedirectStandardOutput = true,
RedirectStandardError = true,
};
}