public static void Profiles(string pathApp, string pathData) { if (Engine.Instance.Elevated != null) { string owner = Environment.UserName; ElevatedProcess.Command command = new ElevatedProcess.Command(); command.Parameters["command"] = "compatibility-profiles"; command.Parameters["path-app"] = pathApp; command.Parameters["path-data"] = pathData; command.Parameters["owner"] = owner; command.DoSync(); } }
public static void Init() { if (m_torDetection) { return; } ElevatedProcess.Command c = new ElevatedProcess.Command(); c.Parameters["command"] = "tor-get-info"; c.Parameters["name"] = "tor"; string customPath = Engine.Instance.Storage.Get("proxy.tor.path"); if (customPath != "") { c.Parameters["path"] = customPath; } c.Parameters["username"] = Environment.UserName; string torInfo = Engine.Instance.Elevated.DoCommandSync(c); foreach (string line in torInfo.Split('\n')) { if (line.StartsWithInv("Name:")) { m_torProcessName = line.Substring("Name:".Length); } if (line.StartsWithInv("Path:")) { m_torProcessPath = line.Substring("Path:".Length); } if (line.StartsWithInv("CookiePath:")) { m_torCookiePath = line.Substring("CookiePath:".Length); } if (line.StartsWithInv("CookiePasswordHex:")) { m_torCookiePassword = ExtensionsString.HexToBytes(line.Substring("CookiePasswordHex:".Length)); } } m_torDetection = true; }
public void Start() { m_command = new ElevatedProcess.Command(); if (Platform.Instance.NeedExecuteOutsideAppPath(ExePath)) { string tempPathToDelete = Utils.GetTempPath() + "/openvpn-" + RandomGenerator.GetHash(); if (Platform.Instance.FileExists(tempPathToDelete)) { Platform.Instance.FileDelete(tempPathToDelete); } System.IO.File.Copy(ExePath, tempPathToDelete); ExePath = tempPathToDelete; DeleteAfterStart = true; } if (IsHummingbird) { m_command.Parameters["command"] = "hummingbird"; m_command.Parameters["gui-version"] = Constants.Name + Constants.VersionDesc; } else { m_command.Parameters["command"] = "process_openvpn"; } m_command.Parameters["path"] = ExePath; m_command.Parameters["config"] = ConfigPath; m_command.ExceptionEvent += delegate(ElevatedProcess.Command cmd, string message) { StdErr.Write("Error: " + message); }; m_command.ReceiveEvent += delegate(ElevatedProcess.Command cmd, string data) { string feedbackType = data.Substring(0, 6); string feedbackData = data.Substring(7); if (feedbackType == "stdout") { StdOut.Write(feedbackData); } else if (feedbackType == "stderr") { StdErr.Write(feedbackData); } else if (feedbackType == "procid") { m_pid = Conversions.ToInt32(feedbackData); if (DeleteAfterStart) { Platform.Instance.FileDelete(ExePath); } } else if (feedbackType == "return") { } }; m_command.CompleteEvent += delegate(ElevatedProcess.Command cmd) { StdOut.Stop(); StdErr.Stop(); if (EndEvent != null) { EndEvent(); } }; m_command.DoASync(); }
public static void WindowsRemoveTask() { ElevatedProcess.Command command = new ElevatedProcess.Command(); command.Parameters["command"] = "compatibility-remove-task"; command.DoSync(); }