Run Process with Administrator privileges in C#

Last Reply 7 months ago By dharmendr

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

 

You are viewing reply posted by: dharmendr 7 months ago.