Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Question
Wednesday, July 8, 2009 8:56 AM
Hi All,
I have written a small C# called SqlExpressInstaller.exe application and in that I am installing the Sql Express using System.Diagnostic.Process class.
Here the problem is that the Sql Express can only be installed by the administrator. So when I run this SqlExpressInstaller.exe as a non administrator then it is failing to install.
So how can I run this SqlExpressInstaller.exe by using the administrator credentials from my another C# application (assume that I have the admin user name and password). Or in other words, I have to run an exe file from my C# application like how we run the exe file by right clicking on that and choose Run As (so that I can select the administrator account to run this exe).
I tried with impersonating the user, but it is not actually impersonating the user. Are there any limitations while impersonating a user from a user account that is having very less previliages?
Please help me out in fixing this issue.
All replies (3)
Thursday, July 9, 2009 5:04 PM ✅Answered | 1 vote
ProcessStartInfo pi = new ProcessStartInfo();
pi.Verb = "runas";
pi.FileName = "notepad.exe";
Process.Start(pi);
Mind the second line which does the trick.Please remember to mark the replies as answers if they answered your question :)
Friday, July 10, 2009 9:28 AM ✅Answered
Hi,
The alternative way I think you can embed the requestedPrivileges in your manifest file within PE file to tell your OS to run your program as administrator as this article told:
Thanks
Binze
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
Thursday, July 9, 2009 5:06 PM
And, if you want to search for more info, UAC is the acronyme used for this thing.Please remember to mark the replies as answers if they answered your question :)