示例#1
0
    public static void Start(string filename, string arguments)
    {
        ProcessStartInfo startInfo = SystemProcess.Prepare(filename, arguments);

        using (Process process = Process.Start(startInfo)) {
            SystemProcess.output = process.StandardOutput.ReadToEnd();
            SystemProcess.error  = process.StandardError.ReadToEnd();
            process.WaitForExit();
        }
    }
示例#2
0
    public static void StartPrivileged(string filename, string arguments)
    {
        ProcessStartInfo startInfo;

        if (SystemProcess.password == default(string))
        {
            startInfo = SystemProcess.Prepare("gksudo", "-p true -D 'MyApplication'");
            using (Process process = Process.Start(startInfo)) {
                SystemProcess.password = process.StandardOutput.ReadToEnd();
                process.WaitForExit();
            }
        }
        startInfo = SystemProcess.Prepare("sudo", "-S " + filename + " " + arguments);
        using (Process process = Process.Start(startInfo)) {
            process.StandardInput.WriteLine(SystemProcess.password);
            SystemProcess.output = process.StandardOutput.ReadToEnd();
            SystemProcess.error  = process.StandardError.ReadToEnd();
            process.WaitForExit();
        }
    }