UAC dialog on Process.Start()
Symptom: You may get Security Warning dialog while launching a process using fully qualified domain name path of the image. The warning dialog does not occur if image path is UNC path.
For example, following piece of code will get the security warning dialog before starting the process
Process p1 = new Process();
1:
2: p1.StartInfo.FileName = "\\\\MyPC.domain.corp.abc.com\\SampleTest\\ABCTest.exe";
3: p1.Start();
4: p1.WaitForExit();
5: p1.Close();
Cause:
The Process.Start() calls ShellExecute() by default. ShellExecute parses the image path string and uses the provider based on it. When it gets fully qualified domain name it uses WebDAV provider which pops up security warning dialog before running the process.
Resolution:
Do not use ShellExecute. Use CreateProcess Instead. Modifying the code as below will launch the process without prompting Security warning.
1:
2: Process p1 = new Process();
3: p1.StartInfo.FileName = "\\\\MyPC.domain.corp.abc.com\\SampleTest\\ABCTest.exe";
4: p1.StartInfo.UseShellExecute = false; //Do not use ShellExecute
5: p1.Start();
6: p1.WaitForExit();
7: p1.Close();
-Ankit
Windows SDK