Solved

Creating a stoppable service

Posted on 1998-06-30
7
1,290 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
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 

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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Recently Microsoft released a brand new function called CONCAT. It's supposed to replace its predecessor CONCATENATE. But how does it work? And what's new? In this article, we take a closer look at all of this - we even included an exercise file for…
In this article, I will show you HOW TO: Perform a Physical to Virtual (P2V) Conversion the easy way from a computer backup (image).
The viewer will learn how to successfully create a multiboot device using the SARDU utility on Windows 7. Start the SARDU utility: Change the image directory to wherever you store your ISOs, this will prevent you from having 2 copies of an ISO wit…
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…

816 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

8 Experts available now in Live!

Get 1:1 Help Now