Down here is the video
using System.Diagnostics;
Process newprocess = new Process();
public Form1()
{
InitializeComponent();
newprocess.StartInfo.UseShellExecute = false;
newprocess.StartInfo.CreateNoWindow = true;
newprocess.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
newprocess.StartInfo.FileName = "netsh";
}
private void button1_Click(object sender, EventArgs e)
{
if (button1.Text == "Start")
{
if (SSID.Text.Length > 0 && Password.Text.Length > 0)
{
progressBar1.Visible = true;
progressBar1.Increment(25);
Method();
button1.Text = "Stop";
}
else
{
MessageBox.Show("No SSID/password","Error");
}
}
else
{
progressBar1.Visible = true;
progressBar1.Increment(50);
newprocess.StartInfo.Arguments = "wlan stop hostednetwork";
using (Process exeProcess = Process.Start(newprocess.StartInfo))
{
exeProcess.WaitForExit();
progressBar1.Increment(100);
button1.Text = "Start";
SSID.Enabled = true;
Password.Enabled = true;
progressBar1.Visible = false;
}
}
}
//Methods
private void Method()
{
newprocess.StartInfo.Arguments = "wlan stop hostednetwork";
using (Process exeProcess = Process.Start(newprocess.StartInfo))
{
exeProcess.WaitForExit();
progressBar1.Increment(25);
Method1();
}
}
private void Method1()
{
newprocess.StartInfo.Arguments = "wlan set hostednetwork mode=allow ssid="+SSID.Text+" key="+Password.Text;
using (Process exeProcess = Process.Start(newprocess.StartInfo))
{
exeProcess.WaitForExit();
progressBar1.Increment(25);
Method2();
}
}
private void Method2()
{
newprocess.StartInfo.Arguments = "wlan start hostednetwork";
using (Process exeProcess = Process.Start(newprocess.StartInfo))
{
exeProcess.WaitForExit();
SSID.Enabled = false;
Password.Enabled = false;
progressBar1.Increment(25);
progressBar1.Visible = false;
}
}
public Form1()
{
InitializeComponent();
newprocess.StartInfo.UseShellExecute = false;
newprocess.StartInfo.CreateNoWindow = true;
newprocess.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
newprocess.StartInfo.FileName = "netsh";
}
private void button1_Click(object sender, EventArgs e)
{
if (button1.Text == "Start")
{
if (SSID.Text.Length > 0 && Password.Text.Length > 0)
{
progressBar1.Visible = true;
progressBar1.Increment(25);
Method();
button1.Text = "Stop";
}
else
{
MessageBox.Show("No SSID/password","Error");
}
}
else
{
progressBar1.Visible = true;
progressBar1.Increment(50);
newprocess.StartInfo.Arguments = "wlan stop hostednetwork";
using (Process exeProcess = Process.Start(newprocess.StartInfo))
{
exeProcess.WaitForExit();
progressBar1.Increment(100);
button1.Text = "Start";
SSID.Enabled = true;
Password.Enabled = true;
progressBar1.Visible = false;
}
}
}
//Methods
private void Method()
{
newprocess.StartInfo.Arguments = "wlan stop hostednetwork";
using (Process exeProcess = Process.Start(newprocess.StartInfo))
{
exeProcess.WaitForExit();
progressBar1.Increment(25);
Method1();
}
}
private void Method1()
{
newprocess.StartInfo.Arguments = "wlan set hostednetwork mode=allow ssid="+SSID.Text+" key="+Password.Text;
using (Process exeProcess = Process.Start(newprocess.StartInfo))
{
exeProcess.WaitForExit();
progressBar1.Increment(25);
Method2();
}
}
private void Method2()
{
newprocess.StartInfo.Arguments = "wlan start hostednetwork";
using (Process exeProcess = Process.Start(newprocess.StartInfo))
{
exeProcess.WaitForExit();
SSID.Enabled = false;
Password.Enabled = false;
progressBar1.Increment(25);
progressBar1.Visible = false;
}
}
No comments:
Post a Comment