cmd.exe returns -1073741502 error code when agent is run as a service but not with agent.bat start

Hello,

We are currently migrating towards TeamCity and we setup our agents to run as a service.

One of our unit tests executes a process (cmd.exe /c echo Hello World) as a different user (a user that is created by the test and added to the Administrator group) and we get the following error:

External Program Failed: cmd.exe (return code was -1073741502). This error code specifies:

"The application failed to initialize properly. Indicates that the application has been launched on a Desktop to which current user has no access rights. Another possible cause is that either gdi32.dll or user32.dll has failed to initialize."

Instead of having our agents run as a service I started them with agent.bat start and now the test passes.

Nb: Both the service Log On account and the account that started the agent with the agent.bat start are the same user.

 

Any idea on how to get this to work with the agents as a service?

0
3 comments
Avatar
Permanently deleted user

Hello Nicola,

 

This may be related to known limitations of Windows service.

Which user is used to run the TeamCity BuildAgent? If it is SYSTEM account, please try to change it.

0

 Hello,

I am using a domain user and not the SYSTEM user.

After reading about the problem online and realizing you can't really execute processes as a different user when running an application as a service we decided to use the agent.bat start and run the agent in a console instead of as a service.

We encountered this problem with the first team we are migrating to TeamCity so I'm sure we will see more problems with running the agent as a service in the future since we have about 20 other teams to migrate. So running the agent in the console is a suitable solution for us.

0
Avatar
Permanently deleted user

Hello Nicola,

 

Making Windows Service be Interactive can also help this case, you can find more information here: https://msdn.microsoft.com/en-us/library/windows/desktop/ms683502(v=vs.85).aspx

0

Please sign in to leave a comment.