How to start a Process as administrator mode in C#

Posted by RP on Stack Overflow See other posts from Stack Overflow or by RP
Published on 2010-03-28T11:54:16Z Indexed on 2010/03/28 12:03 UTC
Read the original article Hit count: 262

Filed under:
|

I have a visual studio windows app project. I've added code to download an installer update file. The installer after it has finished downloading would need administrator privilages to run. I have added a manifest file. When user clicks on the DownloadUpdate.exe, UAC prompts the user for Admin permissions. So i assumed that all processes created and called within DownloadUpdate.exe will run in admin capacity. So i made the setup call my downloaded file with the following code:

Process p = new Process();

p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;

p.StartInfo.FileName = strFile;

p.StartInfo.UseShellExecute = false;

p.StartInfo.RedirectStandardOutput = true;

p.StartInfo.RedirectStandardError = true;

© Stack Overflow or respective owner

Related posts about c#

Related posts about .NET