Instead of args check, you can check Environment. UserInteractive to see if we are in interactive mode or not. Yes it can be done. Your startup class must extend ServiceBase. Have you considered making it a scheduled task instead? Community Bot 1 1 1 silver badge. Mark Ransom Mark Ransom k 40 40 gold badges silver badges bronze badges. I've been thinking about that, too, yes - but then I have a web app, a bunch of SQL jobs, a bunch of Windows service, a bunch of command line tools, and now a bunch of those being used as scheduled tasks Thanks for the input anyway!
I have successfully created applications that can be run from a command line and also installed and run as windows services but I agree with Mark Ransom in at least the fact that they are very different beasts and that you have to be careful with the implementation - especially with the Service.
Like I mentioned in the code comments in my example, don't run any blocking tasks from the OnStart event handler. Rather, start your service on a separate thread or some similar asynchronous construct! Sign up or log in Sign up using Google. Sign up using Facebook.
Sign up using Email and Password. Post as a guest Name. Again, if you do not have administrator previliges you would get the below error. Note that the service name is not the display name of a service. Each service is given a unique identification name which can be used with net or sc commands. For example, Remote procedure call RPC is the display name of the service. But the service name we need to use in the above commands is RpcSs.
So to start Remote procedure call service the command is:. These service names are listed below for each service. The first column shows the display name of a service and the second column shows the service name that should be used in net start or net stop or sc config commands.
Which OS you are trying this on? Verify that you have given the service name correctly. May be the service you are trying to disable is not installed on the OS edition you have. We can see which services are being run in the background by typing services. Also msconfig utility is one of the programs which lets us see which all programs are being started at the startup. Yes, I have the same issue Win 7 Pro. I have had a HDD failure and lost some data, clearly.
Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams? Collectives on Stack Overflow. Learn more. How to create a service running a. Ask Question. Asked 7 years, 4 months ago. Active 7 months ago. Viewed k times. Here's what to do Pradeep atkari. Pradeep atkari Pradeep atkari 1 1 gold badge 7 7 silver badges 14 14 bronze badges.
It does the registry foo for you. This detailed answer helped me, it also describes how to use NSSM. Add a comment.
0コメント