Link to home
Start Free TrialLog in
Avatar of arturosm
arturosm

asked on

Start NT service after installation

Hello experts.

I write a small test program as a Windows "NT" service. I can install / uninstall / start / stop  the service manually without problems and It behaves correctly.

Then I used installshield to do a setup program. I tried to make it start automatically after installation but gives an error of not enough permissions and I have to abort the installation process.

Then I changed the option to not start the service automatically after installation and when I try to start it manually, it does not start.  I also tried with advanced installer and get the same kind of error. I don´t know what could be wrong.

I don´t want to provide user/password because I want to install it in a network with mixed users (domain and out of domain). So for the users not in domain I will not know the user/password.

Any help will be be much appreciated.

Thank you.
Avatar of gtrifidis
gtrifidis

In my opinion you have to check the following :

1) Is there a domain policy that forbits domain users to install service and or applications?
2) As far the non domain users if the account you are using has sufficient rights to install an application or service things should go fine.
3) You could create a batch file to start and stop your service e.g
 net start [yourservicename]
 net stop [yourservicename]
You can read more here
http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/net_start.mspx?mfr=true
What operating system?
Woops...
... and are you wanting to start this service using InstallShield or Delphi. If INstallShield you might also check

http://community.installshield.com/

John
Avatar of arturosm

ASKER

Hi Johnjces,

The client machines will have mainly Windows XP and Vista.
and what about how you want to start the service?
ASKER CERTIFIED SOLUTION
Avatar of Johnjces
Johnjces
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks, let me try it and I will be back maybe tomorrow.
Good luck but do let us know. I am heading out of town (out of the country) and may not get back to you for some time should you ask me a direct question.

John
Hello Johnjces and gtrifidis.

The solutions you provided serve to start and stop a service, that´s ok.

However, the problem I'm having is:

If I install my test service using Delphi (menu: Run/Parameters and use /INSTALL or /UNINSTALL) the service works well. Also if I install it using a command line Start/Run: myservice.exe /INSTALL or /UNINSTALL. In the above examples I have noted no entries are added to the registry. I can start and stop the service from the service manager and the service do it job correctly.

But If I use a MSI package generator such as Install Shield or Advanced Installer, an entry is added to the registry and when I try to start the service using code (Johnjces solution) or command line (gtrifidis solution) I got the 1053 error, "The service did not respond to the start or control request in a timely fashion". The same happens if I use the CreateService Windows API call from Delphi. In all these cases there is an entry added to the registry under services.

What could be the difference in the way delphi or a simple command line installs the service versus the way the API - MSI does it?

I have looked here for solutions to the 1053 error (Delphi), but they were force accepted in my opinion. So I did´t see a solution there.

I would like to use the API to create/start/stop the service because I would have more control if something goes wrong with the installation/functioning of my program. Maybe a second option is to study the error codes from the command line option. What do you think?

I'm using Windows XP in my development machine.

Kind regards.


I cannot help you with an installer, and how they do stuff. Installing and starting a service in Delphi I can. However...

In order for a service to run well, entries in the registry should be made when the service is installed.

Make certain that in your service after install you have something like what's in the code snippet for good operation.

Good luck with your installer... just can't help you there!

John
procedure TCDLibSvrSvc.ServiceAfterInstall(Sender: TService);
var
 Reg : TRegistry;
begin
 NTEventLog.LogInfo('THE CD Library Server Service is installed', 0);
   Reg := TRegistry.Create(KEY_READ or KEY_WRITE);
  try
    Reg.RootKey := HKEY_LOCAL_MACHINE;
    if Reg.OpenKey('\SYSTEM\CurrentControlSet\Services\' + Name, false) then
    begin
      Reg.WriteString('Description', 'Provides a Windows service allowing remote PC clients running THE CD Library! in client mode to control CD Carousels.');
      Reg.CloseKey;
    end;
  finally
    Reg.Free;
  end;
end;

Open in new window

Hi Johnjces.

>I cannot help you with an installer, and how they do stuff. Installing and starting a service in Delphi I can.

In fact, at the end the problem was not the installer tool but the installation of my service which had something wrong but I don´t not exactly what. I start a new service project just to isolate the problem.

What worked was to leave the OnExecute event handler as simple as possible. I could realize the problem was the installation of my service and not the installer tools thanks to the code you provided in your first post regarding this solution.

Thank you again.

Mos.
Thanks for your help.