Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Creating a stoppable service

Posted on 1998-06-30
7
Medium Priority
?
1,432 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 200 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Compliance and data security require steps be taken to prevent unauthorized users from copying data.  Here's one method to prevent data theft via USB drives (and writable optical media).
This article is about my experience upgrading my consulting machine to Windows 10 Version 1709 (The Fall 2017 Creator Update)
In this video, we discuss why the need for additional vertical screen space has become more important in recent years, namely, due to the transition in the marketplace of 4x3 computer screens to 16x9 and 16x10 screens (so-called widescreen format). …
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

916 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