Click here to Skip to main content
15,905,566 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi,

I am new to windows service..

My problem is i have created a windows service in VB.NET. When I install and start the service it is running fine..

Now I try to add a Schedule Task to automatically start the service based on scheduled time.. When Scheduler tries to run.. I am receiving following error..

"Cannot start service from command line or debugger.A windows service must first be installed using installutil.exe and then started with service explorer, Windows services administrative tool or NET start..

I am unable to find solution. Those who really wish to help me for solving this problem can reply..

Thank you in advance..
Posted
Comments
phil.o 24-Feb-14 12:05pm    
What happens when you use the obvious:
net start myservice?
Mylog.25 24-Feb-14 12:23pm    
what is net start myservice.. can you explain it please
Sergey Alexandrovich Kryukov 24-Feb-14 12:43pm    
Let me ask you: why developing a service before you even understand how it is supposed to work? Just read on the topic...
—SA
Eranga Dayarathne 12-Mar-18 7:50am    
i do the same thing and service run well. but meanwhile i debug the programme same error come. why it's appear again.

Did you install the service using INSTALLUTIL??

From the error message you got, probably not, or the installation wasn't successful.
 
Share this answer
 
v2
Comments
Mylog.25 27-Feb-14 5:18am    
Thank you for your reply..

I have installed service using INSTALLUTIL. And one thing Is it possible to start a windows service from Task Schedular or only console application can be run from task Schedular.
Dave Kreskowiak 27-Feb-14 15:23pm    
You can start the service from anywhere you can type the command line to do it. The only problem is you need to have permissions to control services.
Mylog.25 5-Mar-14 1:50am    
Thank you.. Yes it was permission issue and solved it now
A service would start by itself when a computer restarts.
As a result, you don't need to start the service using the task scheduler.
 
Share this answer
 
I see a design issue here as Windows Services are meant for running 24x7. If you are using Schedular to run a task on specific time interval then you can simply develop a console application which performs the required task and then simply ends. That is my 2 cents unless i missunderstood the questions.
 
Share this answer
 
Comments
Dave Kreskowiak 24-Feb-14 17:11pm    
Run 24x7?? No, not really. There are plenty of services that are only started manually and run once in a while.
_Asif_ 25-Feb-14 8:43am    
Yes they do unless there is some exceptional need otherwise an application though registered as Windows Service but set as stopped -> manual setting most of the time does not seem right. The default nature of windows services is that they run under exclusive system account (by default) and lives till the span of system's life. This is an enormous power not available to rest of the applications. If you see live examples of services you will notice that they meant to be run at all time like Web Services, Databases, Network services, Device managements and list goes on and on
Dave Kreskowiak 27-Feb-14 7:19am    
Really? Having been working with Windows since version 1.0, I think you have a slightly distorted view. Open Services.msc and sort the list by Startup Type. Now go look at how many services you have that have a start type of Manual. It's quite a lot.

_Asif_ 28-Feb-14 16:11pm    
What manual has to do with the nature of the service? Manual means services need to be invoked as per user intention. For example Health And Support Service, i don't need this service in normal usage so why i would need to get it loaded in memory, so i changed it to manual giving me the control to load it as and when it is required. But the moment its turn on it will run as independent application till the life of the system or manually put into close mode.

Scheduled Tasks are ideal environment for running applications once in a while tough Windows Services can do this task as well but they are not designed for such small scale tasks. Thats my 2 Cents
Eranga Dayarathne 12-Mar-18 7:51am    
i do the same thing and service run well. but meanwhile i debug the programme same error come. why it's appear again.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900