Problem with ServiceAddService function in Installshield


I have a console application and I want to put it in windows service. I use ServiceAddService to add and start the service.

However, the application just sit there and doing nothing. I try to run it as console and it's working.

So, in resume, my application does not do anything if it is started as service.

Maybe there is an error in my call to ServiceAddService?

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Check the command syntax on the following page from the InstallScript Language Reference:

You can also check for the return value to determine if the ServiceAddService function has finished successfully or not.


  Nayer Naguib
By default, services have no visible console and are not associated with a visible desktop.

To be able to get visible output from a service, it must run under the SystemLocal security context and be typed as ownprocess and interactive.  That will cause the service to be associated with the default interactive desktop (i.e., it will have access most Window's messages if you start a message pump), allowing you display message boxes.  Even then, you'll have no console outout and no shell messages.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
That's right. I misunderstood the question. I thought the authour could not "use" the service, and thought that this might be due to failure to install or start the service. But after re-reading the question, I can see that the author expects the service to output something to the console. cookre has the answer.


  Nayer Naguib
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.