Launch an app running as admin - by passing the filename.sln (UseShellExecute) RRS feed

  • Question

  • Hi all;

    I can call Process.Start(filename.sln) and it launches VisualStudio with that solution.

    But doing so using ProcessStartInfo with Verb="runas" and I get an exception. Even with UseShellExecute=true.

    Is there a way to launch an app running as admin where I pass it the app's data file and don't have the application.exe filename?

    thanks - dave

    Who will win The International Collegiate Programming Championships?

    Thursday, October 18, 2012 12:15 AM


  • 'Runas' can be done only with executables (right click on filename.sln and you won't see 'Run As..' option). So, you must create a ProcessStartInfo with FileName "devenv.exe" and arrgument as "filename.sln".

    ProcessStartInfo startInfo = new ProcessStartInfo();
    startInfo.FileName = "devenv.exe";
    startInfo.Arguments = @"FileName.sln";
    startInfo.Verb = "runas";

    I hope this helps.

    Please mark this post as answer if it solved your problem. Happy Programming!

    • Proposed as answer by Enrique Ferreyra Thursday, October 18, 2012 11:36 AM
    • Marked as answer by DavidThi808 Thursday, October 18, 2012 1:05 PM
    Thursday, October 18, 2012 6:11 AM