I'm trying to create a windows service in which a process should start. This process needs to be logged into another account.
protected override void OnStart(string[] args)
{
_thread.Start();
}
private void ThreadFunction()
{
var process = new Process
{
StartInfo =
{
UserName = "User",
Password = "Pass",
UseShellExecute = false,
FileName = @"C:\Program Files\Default Company Name\ServiceProcessInstaller\ConsoleProcess.exe"
}
};
process.Start();
}
I thought this to be rather simple, but it seems like process.start and windows service are like oil and water.
When I start the process nothing happens and eventually an exception i given: Windows could not start the "AServiceProcess" service on Local Computer. Error 1067: The process terminated unexpectedly.
I would really appreciate all the help I can get and if anything isn't clear enough let me know.