View Full Version : Error 1920 starting NT Service

07-30-2002, 07:37 PM
I've already figured out a workaround for my problem. I'm just posting the info in case someone else hits the same situation.

One of our developers created an NT Service using .NET and included an Installer class. So, all I have to do is set the ".NET Installer Class" to Yes in the Component properties and everything is taken care of for me. I don't have to define anything under the component's "Advanced Settings\Install NT Services".

After getting the service to install, I decided to add a "Control NT Services" entry to stop the service on uninstall and install (if it's being upgraded). After I verified that it would properly stop the service, I decided to try starting the service on Install. This caused runtime Error 1920 and displayed a message that I might need elevated privileges.

After a little troubleshooting, I realized that the service has not actually been installed when the StartService action is called in the InstallExecuteSequence table. I'm not positive but, I believe that the .NET component's Installer class doesn't get called until the InstallFinalize action is called.

So, the solution was to create a custom action (vbscript w/ code included in the CA) to start the service and to make sure it gets executed sometime after InstallFinalize:
Option Explicit
Dim WshShell
Set WshShell = CreateObject("WScript.Shell")
WshShell.Run "net.exe start ""Henwood Remote Messaging""", 0

The code above requires windows scripting host but that's no problem for my target platforms. The "0" at the end of the .Run command tells it to hide the command window.

Hope this helps.

- Aaron Ford
Henwood Energy Services, Inc.

01-29-2007, 03:23 PM
Thank you for this Aaron! I have be scouring looking for a solution to this problem.

Thanks for sharing!

Christopher Painter
01-29-2007, 04:15 PM
This `solution` is frought with problems. The biggest of which is that during an elevated installation ( or UAC on Vista ) that the interactive user may not have Administrator privlidges after InstallFinalize.

The real solution is to take the developer who wrote the Installer Class custom action out back and shoot him. Drop the CA and use the ServiceControl and ServiceInstall tables and you wouldn't have this problem in the first place.