C # Process example

Source: Internet
Author: User

For security considerations, the company imposes permission restrictions on the Windows operating system used by employees. If you want to install additional software on your own machine, you need to contact the system administrator! It feels quite uncomfortable!
However, to ensure the normal operation of our programmers, we are allowed to run vs2010 with the administrator privilege, which leaves a backdoor for us to indirectly obtain the administrator privilege to install the software we want. By the way, we need to log on to vs2010 with the Administrator permission and open the required exe file through the process class.
 
The code is relatively simple. You can create a winform project, add a button control, and add an OpenFileDialog control.
 
Private void runBtn_Click (object sender, EventArgs e)
{
DialogResult dialogResult = openFile. ShowDialog ();
OpenFile. InitialDirectory = "d :\\"; // note that c: \ instead of c: \ is used to write the path here :\
OpenFile. Filter = "text file | *. * | all files | *.*";
OpenFile. RestoreDirectory = true;
OpenFile. FilterIndex = 1;
If (openFile. ShowDialog () = DialogResult. OK)
{
String fileName = openFile. FileName;
Process myProcess = new Process ();
Try
{
MyProcess. StartInfo. UseShellExecute = false;
MyProcess. StartInfo. FileName = openFile. FileName;
MyProcess. StartInfo. CreateNoWindow = true;
MyProcess. Start ();
}
Catch (Exception ex)
{
Console. WriteLine (ex. Message );
}
}
}
Author: kbh1983

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.