Advertisement
Guest User

Untitled

a guest
Jun 26th, 2017
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.97 KB | None | 0 0
  1.  private void button2_Click(object sender, EventArgs e)
  2.         {
  3.             textBox3.Text = path;
  4.             textBox2.Text = password;
  5.             textBox3.Text = username;
  6.  
  7.             var secure = new SecureString();
  8.             foreach (char c in textBox2.Text)
  9.             {
  10.                 secure.AppendChar(c);
  11.             }
  12.  
  13.             System.Diagnostics.Process process = new System.Diagnostics.Process();
  14.             System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
  15.            
  16.             startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
  17.             startInfo.UserName = username;
  18.             startInfo.Password = secure;
  19.             startInfo.FileName = "cmd.exe";
  20.             startInfo.Arguments = String.Format("/C cmd /K \"{0}\"", path);
  21.                
  22.             process.StartInfo = startInfo;
  23.             //startInfo.UseShellExecute = false;
  24.             process.Start();
  25.  
  26.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement