Solved

Creating a stoppable service

Posted on 1998-06-30
7
1,276 Views
Last Modified: 2013-12-28
I've tried to create a service on a NT4.0W using the sc.exe included in the resource kit. The service is created without problems and so is the start. However, when I try to stop the service NT responds that this action is not allowed. I have done a SC query on the service and it tells that the state of the service is started, NON-STOPPABLE, NON-PAUSABLE and IGNORES-SHUTDOWN.

I'd like to change this state to STOPPABLE, PAUSABLE and not to ignore shutdowns.

How can this be done?

Thanks,
Teddy.

Btw, I've tried the same using the SRVINSTW.EXE file with the same results.
0
Comment
Question by:tflarsen
7 Comments
 
LVL 5

Expert Comment

by:carmine
ID: 1783747
Your program has to accept the api calls to perform these tasks, otherwise service manager cannot do these things.  If you're just running a 'standard' program as a service then they will not be available.  The only way to stop this type of 'service' is to kill it from task manager.
0
 
LVL 2

Expert Comment

by:connex
ID: 1783748
Hmm, can you explain why you reject the answer without comment?
It's quite a fact that only programs that respond to certain
signal/messages/apicalls can be used es stopable services.
You _CAN_ Manupulate the flags, but it will result in messing things
up as the program itself does not support the stopping, but nt at some point thinks it's stopped .)

To write a "clean" service is the better option. There are lot's of samples out there and even skeleton-code.

0
 
LVL 1

Accepted Solution

by:
sstew earned 100 total points
ID: 1783749
Use instsrv <servicename> <path>srvany.exe
  Where <servicename> is the name of your new service, with No spaces. You will also need to specify the full path to the srvany.exe.

Then run Regedt32. Find the registry entry for your service.
Add a Parameters key.
Under Parameters, add the values:
  Application
  AppParameters
The application value should hold the fully qualified filename of the program you want to become a service.
The AppParameters holds any parameters you need.

You can also change the Display Name here to something a bit more meaningful if you want.
0
Promote certifications in your email signature

Has your company recently won an award or achieved a certification? They'll no doubt want to show it off. Email signature images used to promote certifications & awards can instantly establish credibility with a recipient and provide you with numerous benefits.

 

Author Comment

by:tflarsen
ID: 1783750
The problem is that I have a database program that I need to stop at a given time before I can backup the database.

The program runs on a Windows NT server which is locked and therefore I can't write a script that simply shuts down the program.

I haven't written this program and it was not written exclusively for NT and that's why the API layer for the service calls isn't implemented.

I rejected the last answer you gave me because the way I see it is that you can't just say that it isn't possible to do so and expect to gain points from that. Instead, that could have been mentioned in a comment as a piece of information instead.
0
 
LVL 5

Expert Comment

by:carmine
ID: 1783751
I can see why you might what extra comments, but it would be helpful to qualify your rejection with this as a reason. But if it can't be done, then how are you ever going to close the question?
0
 
LVL 1

Expert Comment

by:hajek
ID: 1783752
Well, you'll have to decide, what you want: a service is quite specially written program, which can be run without user login.   You do not have such program, but you have a way (sc.exe), how to  start it as service.
  But like a lot of other stuff NT service implementation is poor,  you can not do with non-standard service everything what is possible with standard services.

  I believe you database program has kinda "start command" and "stop command". If you can not set up what is "stop command" for the service and "service manager" (lets call it so) uses only API  calls for maintaining of running services, you can not stop it regularly.
  But you can -I believe- run the "stop command", to stop the database, then to do back up and run "start command" again. I do not know whether "service manager" even notice this - but I doubt.

How exactly do you start and stop the database ?
0
 
LVL 1

Expert Comment

by:hajek
ID: 1783753
Sorry, I have not noticed - you can not write the script to stop the program ?? They told you "here is NT server, you have to backup it but you can not even touch it" ??? Who (what) and how is to stop the service and make backup ?
0

Featured Post

Why spend so long doing email signature updates?

Do you spend loads of your time carrying out email signature updates? Not very interesting are they? Don’t let signature updates get you down. Let Exclaimer Cloud - Signatures for Office 365 make managing email signatures a breeze.

Join & Write a Comment

Several part series to implement Internet Explorer 11 Enterprise Mode
Storage devices are generally used to save the data or sometime transfer the data from one computer system to another system. However, sometimes user accidentally erased their important data from the Storage devices. Users have to know how data reco…
With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…
The Task Scheduler is a powerful tool that is built into Windows. It allows you to schedule tasks (actions) on a recurring basis, such as hourly, daily, weekly, monthly, at log on, at startup, on idle, etc. This video Micro Tutorial is a brief intro…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now