Not sure this is correct, Herfried . 1) The user doesn't mention "the
desktop" does he? 2) In any case, Services can for sure interact with the
current desktop (if it's loaded) if they so wished. Why do you say they
cannot?
Anyway... Dave M,
1) you mention a "database." Services are typically set to run under the
Local System account and are limited in their network access. Have you tried
running your service under a different user account (you can configure this
in Windows' Computer Management console). But that brings up another
question....
2) I'm not sure if processes spawned using "Shell" inherit the environment
of the caller program if the caller is a service. They probably do. I'm
almost sure of it. But you may need to look into Process.Start (and possibly
ProcessStartInfo if you need fine-grained control) to spawn your process and
get it to work right with the right privileges.
--
-C. Moya
www.cmoya.com
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:eD**************@TK2MSFTNGP12.phx.gbl...
"dave m" <da***@nexcortech.com> schrieb:I have a small application that launches an application via the shell
function when a listening socket receives data from another PC. This
works fine using a WinForms environment.
However, I want this listing app to run in the background as a service.
When debugging the service, the line -
ID = Shell("C:\TestApp.exe", AppWinStyle.NormalFocus)
returns a PID value, executes without errors, but the program
"TestApp.exe" doesn't start. Task manager show TestApp as a running
process, but it really didn't because it would have incremented a value
in a database.
This doesn't work "by design". Services can even run if no user is logged
on and thus cannot have access to the desktop. I suggest to rethink
whether a service is the right choice. Maybe an application which gets
started when the user logs on is a viable alternative.
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>