0

I am trying to have a service running on a Windows Server 2008 R2 be able to execute dcpromo in order to join and remove AD. In Server 2003, I was able to simply use Process.Start() in C# and provide the path to dcpromo and the path to the answer file provided by a user.

However, in Server 2008, this returns FileNotFoundException. I have verified the path to dcpromo, and have even tried running other executables in the System32 folder like ipconfig and whoami which execute just fine.

The service is running as Local System account and the only way I have found to get it to work is save the command to a batch file and impersonate an Administrator to execute the batch file. But this has it's own issue like requiring an Administrator's password.

According to the permissions on the dcpromo.exe, the SYSTEM account has read/execute permissions, and I have tried giving full permissions and changed the owner to SYSTEM, but none of this helped. The same code works if ran by a user as a regular application (i.e. not a service).

Any idea how to grant SYSTEM account permissions to execute dcpromo while running under a service in Server 2008 R2?

2 Answers2

0

Can you change the service to run as user instead of the system account?

Jason
  • 31
  • 2
  • The problem with that is if/when it does run dcpromo to become part of a domain, the local account that it was running as disappears. The system wasn't designed for users to log in directly and so it might become difficult to change the user the service runs as. – Punkster812 Feb 07 '13 at 19:53
-1

I've been having this problem and realized that DCPromo is a 64-bit process and you probably have Visual Studio set to create x32 apps. Well, I changed VS to compile in 64-bit and it worked like a champ!

Carlos