I have a windows service installed on my PC and I have another application which checks whether the service is running and only if the service is running does my application open up. And my issue here is every time my system restarts the service which is set to startup Automatic (Delayed Start) goes into Starting mode and remains in that state like forever and I then have to use the task manager to end the service task and then start the service and it works fine from there on. How do I fix this issue. Thanks in advance
Related
I have a small tray app which should inform the user about start and stop of an execution of an other process running under local system account. The process running with local system account is called by another service (not owned by me). "My service process" is always running just for a short time. So I can not implement a wcf callback handling. Everything works fine on my machine. But it is not running at the customer side.
The problem (exception) which occurs at the customer side is something like "there is no endpoint listening on net.pipe..."
But the tray is running.
I created a test app (console) to communicate with the tray. This works fine.
If I start this test app with psexec -I ... to run it with a local system account it is also running.
I have no idea about possible reasons and so I have two questions:
is it "allowed" to host a wcf service in a tray app (running in user context) and call it by a process running in local system account?
if yes, is there a possible policy/security setting which can prevent this functionality?
The only workaround I could think off is to create a helper service which I can use as some kind of a broker (connect from tray with a callback interface which could be used by the other process). But this seems to be a big overhead...
The answer is, it is not possible.
The reason is explained here: Connecting via named pipe from windows service (session#0) to desktop app (session #1)
It looks like my test was successful, because psexec was still running in session #1.
My implementation is now using the already above described workaround
I created a service using .NET that is supposed to start automatically and run as a User with my username & password.
If I restart my PC, log on with the same username & password, and go to Task Manager, it says that the service is running, but when I check the Event Log there are no messages stating that the service has started, and in fact, the service has not started, because it doesn't do what it's supposed to be doing.
On the other hand, if I manually stop and start the service, then the entries in the Event Log appear and the service runs as it's supposed to.
So when I restart my PC, how come Task Manager says that the service is running even though it's not running? Is there a security setting that I need to tweak?
Does your service have a dependency on another Windows service? If so then it may be that your service is failing to initialize correctly when the machine restarts as it can't make use of the functionality in needs from the dependent service.
This would explain why if you restart the service is works correct.
I was able to solve the problem: the service was failing to initialize properly on windows restart because it was not dependent on any service, when it should have been dependent on the event log service. Setting the "ServicesDependedOn" property of the ServiceInstaller object to "Windows Event Log" solved the problem. Thanks for the help!
I have a bat file which is installed as a service. I can run the service on a remote box. This service needs to launch another application. The launched application needs to be visible(run in foreground). Currently the launched application is running in background as the windows service is running in background. How can i make the windows service or both the windows service and the application that it launches run in foreground? I intend to manage the service with the ServiceController class in C#.
I think you should probably read
http://asprosys.blogspot.com.au/2009/03/allow-service-to-interact-with-desktop.html
Making a service to just launch another app is a real security issue, what if your other app gets replaced with something else do you have all the checks in your Service to ensure your app is the app you think it is.
A proper approach is to launch the second application in the user's session, while your Windows service app always runs in session 0.
The approach has been part of my discussion with #RaheelKhan under this thread,
How reliable is adding an application manifest to ensure elevated privileges across windows xp, vista and 7?
It requires proper understanding of Windows sessions, session isolation, and platform invoke.
I created a server application that always need to be online and running.
In case that my application is been shutdown i want to restart the application.
Is there a way that "Windows service" will be my online insurance?
If not is there another way?
Thanks.
Yes, windows services can be set to restart if they fail.
In case that my application is been shutdown i want to restart the application.
This makes NO Sense and you should not do it.
If the admin shuts you down (and that is the only way a service is shut down) then he has a reason - maybe he has to apply emergency patches or something else.
If the app CRASHES that is another thing (and windows services can be set up to automatically restart when crashing), but if you geta shutdown request do NOT restart as a service. Never. I can name you a dozen cases where it would be stupid - mostly around system maintenance that you would interfere with. You basically risk being terminated because the computer is switched off.
If your application is not a windows service you need to learn the basics how windows works, because it is ridiculously crappy to have a normal application act as sever process. For anything, a user must be interactively logged in. Next time I see a server with a logged in user because some stupid programmer could not do his job I promise I (censored).
I have WCF service which launches the remote process from Process.Start successfully on stand alone machine where this WCF service is hosted/deployed and developed.
I deployed this as whole service on another machine, and run the service on that machine as well, execute the service on the same code area which launches the process remotely, here it failed, Strange behavior.
I checked the process state stand alone , and launched the process normally, it executed fine and shown the message box inside that process which was written there. BUT when this process launched via WCF call from code, process didn't launched in interactive manner, Task Manager shown the launched process, but its console not shown, nor any message box shown . ANY IDEA ? or WAY AROUND?
Note : This behavior is observed when WCF service deployed completely with all binaries on another machine
Regards
Ehsank
Services should generally not have any user interface. The same thing goes for processes that services might start.
It works on your development machine because you are developing/debugging it with a valid, active logged-on user (you). the same is not the case when running as a more traditional service on a normal server.