我可以调用Process.Start(filename.sln)并使用该解决方案启动VisualStudio。
但是使用带有Verb =“runas”的ProcessStartInfo这样做,我得到一个例外。即使使用UseShellExecute = true。
有没有办法启动以管理员身份运行的应用程序,我将应用程序的数据文件传递给它并且没有application.exe文件名?
答案 0 :(得分:0)
找到答案 - 当您以管理员身份运行时,您只能为其提供可执行文件,而不是运行程序的应用程序。所以你必须传递devenv.exe,而不是filename.sln
答案 1 :(得分:0)
ProcessStartInfo processInfo = new ProcessStartInfo(); //new process class
processInfo.Verb = "runas"; //wanna admin rights
processInfo.FileName = sDevPath + "devenv.exe"; //exe file path
processInfo.Arguments = sPrjPath + "mConverter.sln"; //sln file as argument
try
{
Process.Start(processInfo); //try to start
}
catch (Win32Exception)
{
//oops
}