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