Solved

Creating a stoppable service

Posted on 1998-06-30
7
1,300 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
Connect further...control easier

With the ATEN CE624, you can now enjoy a high-quality visual experience powered by HDBaseT technology and the convenience of a single Cat6 cable to transmit uncompressed video with zero latency and multi-streaming for dual-view applications where remote access is required.

 

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to remove unwanted words? 34 49
Cleaning up a desktop after leaving a domain 3 40
Reinstall Windows 10 3 26
OS Selection Menu 1 47
Our Group Policy work started with Small Business Server in 2000. Microsoft gave us an excellent OU and GPO model in subsequent SBS editions that utilized WMI filters, OU linking, and VBS scripts. These are some of experiences plus our spending a lo…
Today, still in the boom of Apple, PC's and products, nearly 50% of the computer users use Windows as graphical operating systems. If you are among those users who love windows, but are grappling to keep the system's hard drive optimized, then you s…
This Micro Tutorial will give you a basic overview of Windows DVD Burner through its features and interface. This will be demonstrated using Windows 7 operating system.
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …

830 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