I want the C# code to open a program using a shortcut. The program requires admin privileges.
Whilst ensuring Visual Studio is running as administrator, I have tried:
System.Diagnostics.Process proc = new System.Diagnostics.Process();
proc.StartInfo.FileName = "FN.lnk";
proc.StartInfo.UseShellExecute = true;
proc.StartInfo.Verb = "runas";
proc.Start();
This fails with the exception: 'The operation was canceled by the user'.
Replacing "FN.lnk" with "cmd.exe" runs a command prompt window with admin privileges...
I have also tried:
System.Diagnostics.Process.Start("CMD.exe", "/K FN.lnk");
which launches an elevated command prompt window, but still says "Access is denied"
If I run cmd as administrator and manually navigate to the folder to run FN.lnk, it works perfectly... which makes this problem even more confusing.