Run Process with Administrator privileges in C#

SajjuAhmed
 
on Oct 29, 2018 12:09 AM
11183 Views

Hi, I am having an web application which requires run as administrator for running few cmd lines. Locally it works fine. Now when I deployed it to IIS server. It is not running. The reason is it's not running the project in administration mode. Please suggest some solution. It's mandatory for my application to run in administration mode.

var startInfo = new System.Diagnostics.ProcessStartInfo
{
    UseShellExecute = false,
    Verb = "runas",
    WorkingDirectory = @"C:\\OracleATS\\openScript",
    WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden,
    FileName = "cmd.exe",
    RedirectStandardInput = true,
    RedirectStandardOutput = true,
    RedirectStandardError = true,
    Domain = "mydomainname",
    CreateNoWindow=false,
    UserName = Environment.UserName,
    Password = secureString
};

 

Download FREE API for Word, Excel and PDF in ASP.Net: Download