Run Process with Administrator privileges in C#

Last Reply 22 days ago By dharmendr

Posted 22 days ago

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
};