469,926 Members | 2,497 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,926 developers. It's quick & easy.

Windows Setup Project - Installing an .exe with a service

Hello:

I wrote an .exe that I would like to be called by a service I am
deploying to a server. However, I am not sure how to tell the setup
project to include the .exe.

Also, I do not know how to tell the service where the .exe actually
resides on the server. I would like to prevent hard-coding it since
the software will be distributed to different offices in my company.

Is it possible to include an .exe and to tell the service where to
find it?

Thanks,
Travis

Nov 2 '07 #1
1 1606
I solved my own issue. I found a web site that suggested putting
[TARGETDIR] into the registry view. That worked like a charm! It
stores the installation directory into the registry, which I retrieve
later on in my service.

-------------------------------------------------------------------------------

For a little background, I had written a service that checked whether
user's passwords were about to expire on our LDAP server. However, for
some reason, Windows Services seem incapable of handling the exception
correctly. Even though I would surround the entire service in try/
catch blocks, the exceptions would still terminate the program every
time. I am not sure if this is a Microsoft issue or a Novell issue.

Well, I tried a lot of things to prevent the service from stopping.
People on this forum were suggesting all kinds of crazy things and
none of their suggestions helped (some didn't make sense). Then
someone finally made me aware that Windows services operate with
different apartments than most applications. Somehow this affects how
services handle exceptions. That wonderful person suggested that I
separate the service code from the body code. However, they suggested
making a COM library and invoking it using some weird stuff I have
never heard of.

I took the simpler approach and just tried to make a library. However,
the library approach didn't work because the library methods were
being run under the service, which is essentially no different than
having them inside the service. I wasn't daunted, though, and I simply
made the library into a Console application and added a Main method.
Now my service simply executes the console application. Since Console
applications don't suffer from the strange exception handling gook
that services do, my errors are handling correctly . . . which means
my service has the benefit of just calling the console application
every some many hours. It is a nice separation of responsibility - now
I have a very nice shell for future services.

The only problem I had to figure out was how to get my service, which
runs with a path under System32 (that's default) to execute my console
application in my application directory. I simply put [TARGETDIR] in
the registry when the setup project runs and I can access it in my
service. Huzzah!

Thanks to everyone who tried to help me resolve my issue, I'm just
glad to be done with it, finally.

~Travis

Nov 2 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Theresa Smallwood | last post: by
3 posts views Thread by Jeremy S. | last post: by
4 posts views Thread by bob lambert | last post: by
reply views Thread by =?Utf-8?B?U2ltb25EZXY=?= | last post: by
5 posts views Thread by dm3281 | last post: by
reply views Thread by =?Utf-8?B?QWxoYW1icmEgRWlkb3MgRGVzYXJyb2xsbw==?= | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.