[.NET 2.0] Process / ProcessStartInfo with specified account

  • Thread starter Alexander van Doormalen
  • Start date
A

Alexander van Doormalen

I am trying to run an external process (command tool) within a Windows
Service with the specified account. When the application launches I get
a error dialog with the following message:

Application popup: <COMMAND TOOL> - Application Error : The application
failed to initialize properly (0xc0000142). Click on OK to terminate
the application.

I use the following code to start the process (not relevant code is
stripped):

using (Process commandTool = new Process())
{
ProcessStartInfo startInfo = commandTool.StartInfo;
startInfo.FileName = commandToolPath;
startInfo.Arguments = arguments;
startInfo.UseShellExecute = false;
startInfo.RedirectStandardError = true;
startInfo.RedirectStandardOutput = true;
startInfo.RedirectStandardInput = true;
startInfo.CreateNoWindow = true;
startInfo.Domain = domain;
startInfo.UserName = username;
startInfo.Password = password;

commandTool.Start(); // -> Fails here with error dialog!

if (!commandTool.HasExited)
{
int timeout = this.configuration.QuotaCommandToolTimeout;

if (timeout > 0)
{
commandTool.WaitForExit(timeout); // With configured timeout
}
else
{
commandTool.WaitForExit(); // Without timeout
}
}

string errorOutput = commandTool.StandardError.ReadToEnd();
string infoOutput = commandTool.StandardOutput.ReadToEnd();
}

When starting the process without the account information it starts
fine only it doesn't work, as I need a domain service account.

Anybody has a idea how to solve this?
 
W

Willy Denoyette [MVP]

|I am trying to run an external process (command tool) within a Windows
| Service with the specified account. When the application launches I get
| a error dialog with the following message:
|
| Application popup: <COMMAND TOOL> - Application Error : The application
| failed to initialize properly (0xc0000142). Click on OK to terminate
| the application.
|
| I use the following code to start the process (not relevant code is
| stripped):
|
| using (Process commandTool = new Process())
| {
| ProcessStartInfo startInfo = commandTool.StartInfo;
| startInfo.FileName = commandToolPath;
| startInfo.Arguments = arguments;
| startInfo.UseShellExecute = false;
| startInfo.RedirectStandardError = true;
| startInfo.RedirectStandardOutput = true;
| startInfo.RedirectStandardInput = true;
| startInfo.CreateNoWindow = true;
| startInfo.Domain = domain;
| startInfo.UserName = username;
| startInfo.Password = password;
|
| commandTool.Start(); // -> Fails here with error dialog!
|
| if (!commandTool.HasExited)
| {
| int timeout = this.configuration.QuotaCommandToolTimeout;
|
| if (timeout > 0)
| {
| commandTool.WaitForExit(timeout); // With configured timeout
| }
| else
| {
| commandTool.WaitForExit(); // Without timeout
| }
| }
|
| string errorOutput = commandTool.StandardError.ReadToEnd();
| string infoOutput = commandTool.StandardOutput.ReadToEnd();
| }
|
| When starting the process without the account information it starts
| fine only it doesn't work, as I need a domain service account.
|
| Anybody has a idea how to solve this?
|

If you are running the service in a SYSTEM logon session on XP SP2 or W2K3,
you'll need to run your service on another account (LocalService or
NetworkService f.i). Both W2K3 and XP SP2 don't allow you to spawn another
process with alternate credentials when launched from the SYSTEM logon
session.

Willy.


Willy.
 
A

Alexander van Doormalen

The service runs with its own service account which is required by the
software vendor.
 
Joined
Aug 31, 2010
Messages
1
Reaction score
0
Did anybody found a solution for this? I'm having a very similar situation...
My process is invoked by an Integration Service package; that SISS package is invoked from a SQL Server 2005 job.

The SQL Server Agent (MSSQLSERVER) service is running under a domain user (not Network Service or Local System).

Any ideas?

Thanx!
Regards
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top