I have a WCF service (exe) that I started via a console app using a different credential by passing the Domain, UserName and Password in the ProcessStartInfo() information. Using the code, the value for 'User name' in Task Manager for the 'exe' is 'TestUser'
var dpmProcess = new Process
{
StartInfo = new ProcessStartInfo()
{
WorkingDirectory = "C:\\Debug",
FileName = "",
UseShellExecute = false,
CreateNoWindow = true,
WindowStyle = ProcessWindowStyle.Normal,
Domain = "xx",
UserName = "TestUser",
Password = password, /*using SecureString*/
Verb = "runas"
}
};
dpmProcess.Start();
I tried to do the same in a Windows Service Code, but my exe is not started. I used 'Impersonation' and my exe was started. However, the 'User name' in the Task Manager is 'SYSTEM' and not the 'UserName' (TestUser) I passed in Impersonation.
//*start impersonator (2)
using (var imp = new Impersonator(LOGIN, DOMAIN, PASSWORD))
{
WriteToFile("Starting..");
var dpmProcess = new Process
{
StartInfo = new ProcessStartInfo()
{
FileName = "xxx",
RedirectStandardOutput = true,
RedirectStandardError = true,
RedirectStandardInput = true,
UseShellExecute = false,
CreateNoWindow = true,
ErrorDialog = false,
WindowStyle = ProcessWindowStyle.Hidden
}
};
dpmProcess.Start();
WriteToFile("Started..");
}
Is it possible to start exe in Windows Service and see the Username as same as running the exe in Console App?
Thanks!