private void ExecuteCommand(string command, string arguments) { bool errorFound = false; bool hotspotSupported = true; Process processInstance = new Process(); processInstance.StartInfo = new ProcessStartInfo { FileName = command, Arguments = arguments, RedirectStandardOutput = true, UseShellExecute = false, WindowStyle = ProcessWindowStyle.Minimized, CreateNoWindow = true }; processInstance.Start(); processInstance.BeginOutputReadLine(); processInstance.OutputDataReceived += (obj, evt) => { if (evt.Data != null) { logs.Add(evt.Data); if (logs.Last().Substring(0, 4) == "[ER]") { errorFound = true; if (logs.Last().Contains("Hotspot Not Supported on WiFi Card")) { hotspotSupported = false; logs.Add(string.Format("[{0}] Applicaion will now Exit!", DateTime.Now)); } } } }; processInstance.WaitForExit(); if (errorFound) { AlertForm alertForm = new AlertForm("Error Found!", logs.ToArray()); alertForm.ShowDialog(); if (!hotspotSupported) { this.Close(); } } else { lbl_status.Text = "Hotspot Started!"; } }
private void Help_LinkClicked(object obj, LinkLabelLinkClickedEventArgs evt) { string[] textData = @"File Name: WiFi-Hotspot Description: -This application is written in C# accompanied with 2 scripts written in Python. These script is required for the Hotspot to be established and to generate a Security Key for the Hotspot. Email me: [email protected]".Split("\n".ToCharArray()); AlertForm helpForm = new AlertForm("About", textData); helpForm.ShowDialog(); }
/* * Will run only once, at the start of the program * It is used instead of Form_Load so that the MainForm is * fully loaded. */ private void OnLoad(object obj, EventArgs evt) { if (!(File.Exists(Directory.GetCurrentDirectory() + "\\hotspot-win32.py") || File.Exists(Directory.GetCurrentDirectory() + "\\random-all.py"))) { string[] error_log = { string.Format("[Err][{0}] Script(s) Missing!", DateTime.Now), string.Format("[{0}] Applicaion will now Exit!", DateTime.Now) }; AlertForm alertForm = new AlertForm("Files Missing!", error_log); alertForm.ShowDialog(); this.Close(); } else { ExecuteCommand("python", string.Format("hotspot-win32.py start \"{0}\" \"{1}\"", ssid, key)); lbl_ssid.Text = string.Format("SSID: {0}", ssid); lbl_key.Text = string.Format("KEY: {0}", key); this.Activated -= new EventHandler(OnLoad); this.Activated += new EventHandler(OnActivated); } }
private void Logs_LinkClicked(object obj, LinkLabelLinkClickedEventArgs evt) { AlertForm logForm = new AlertForm("Logs", logs.ToArray()); logForm.ShowDialog(); }