Launch app from a Windows Service

G

Guest

Not only does the "solution" have a service app and installer, it has a Tray
Icon app that allows a user to send custom commands to the service.

The installer launches the service and the tray app in the commit phase.
The service app is automatic, so it is up and running whenever the computer
reboots. However, I need the tray app to be launched automatically, also.

The installer uses Process.Start("C:\MyPath\MyApp.exe") to launch the tray
app, which works fine.

The service app uses the same thing in its "OnStart" code, but it does not
work there. No errors, it just does not work. I write to the event log just
before and just after Process.Start, so I can confirm that the code path is
executed.

What do I need to do to have my service app start the tray app when the
service is started?

(The tray app uses a mutex to prevent muliple copies of the tray app).

Thanks,
 
J

Jani Järvinen [MVP]

Hello Jon,

which operating system version are you deploying your service to? Based on
your message, I'd assume it could be Windows Vista.

If so, you need to be aware of new service hardening features in Vista:

http://www.microsoft.com/technet/te...chnet/technetmag/issues/2007/01/SecurityWatch

In case of Vista, you could in fact start your tray application from your
service (thus no error messages), but since the tray application would then
run in a different session, the user wouldn't see the tray icon. See also
here:

http://blogs.msdn.com/oldnewthing/archive/2007/05/08/2470754.aspx

My suggestion is that you would separate the starting of the service from
starting the tray application, and make the tray application start for
example by using the regular Start/Startup folder, for example.

Hope this helps.

--
Regards,

Mr. Jani Järvinen
C# MVP
Helsinki, Finland
(e-mail address removed)
http://www.saunalahti.fi/janij/
 
G

Guest

Thank you very much.
which operating system version are you deploying your service to? Based on
your message, I'd assume it could be Windows Vista.
Windows XP
Nevertheless, what you said makes sense. The service operates in
LocalSystem, so the app it launches might not be visible to the normal user
id.
My suggestion is that you would separate the starting of the service from
starting the tray application, and make the tray application start for
example by using the regular Start/Startup folder, for example.
I have been trying that, but have been unable to get the installer to put
the right shortcut into the startup folder (and onto the desktop). It LOOKS
like the right thing, but the shortcut launches an installation procedure
instead of the tray app.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top