My current situation is that I need to execute an exe(which creates a local .txt file) in remote server with IIS hosting an ASP.net/C# API. I created a local user(say userA)
You can use Process.Start
Process process = new Process();
process.StartInfo.FileName = "CVS.exe";
process.StartInfo.Arguments = "if any";
process.Start();
There is also a post about running processes as another user in asp.net:
http://weblogs.asp.net/hernandl/archive/2005/12/02/startprocessasuser.aspx
Supplying user credential
In short it says that you must redirect the process, with code like this:
ProcessStartInfo info = new ProcessStartInfo("cmd.exe");
info.UseShellExecute = false;
info.RedirectStandardInput = true;
info.RedirectStandardError = true;
info.RedirectStandardOutput = true;
info.UserName = dialog.User; // see the link mentioned at the top
info.Password = dialog.Password;
using (Process install = Process.Start(info))
{
string output = install.StandardOutput.ReadToEnd();
install.WaitForExit();
// Do something with you output data
Console.WriteLine(output);
}