I have written a WCF service API which will create process inside to convert something for my application, also this service deployed in IIS in windows server using windows authentication. I used below code to run c# .exe but not running. If I run below code without username and password .exe is running but as SYSTEM
user. I want to run this exe with specified user name.
public byte[] InvokeShtToPdfConvertor(string userId, string connectionAlias)
{
try
{
using (Process shtToPdfProc = new Process())
{
shtToPdfProc.StartInfo.FileName = Constants.SHT_PDF_CONVERTOR_APP_PATH;
shtToPdfProc.StartInfo.Arguments = userId + " " + connectionAlias;
shtToPdfProc.StartInfo.Verb = "runas";
shtToPdfProc.StartInfo.UserName = _tempUserName;
shtToPdfProc.StartInfo.Domain = "cw01.contiwan.com";
shtToPdfProc.StartInfo.Password = ConvertToSecureString("ABCDFEDD");
shtToPdfProc.StartInfo.UseShellExecute = false;
shtToPdfProc.Start();
shtToPdfProc.WaitForExit();
}
}
catch (Exception ex)
{
throw new FaultException<MplCustomException>(new MplExceptionHandler().MplExceptionHandlerMethod(ex));
}
return GetPdfFilePath(userId);
}