Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Creating a stoppable service

Posted on 1998-06-30
7
Medium Priority
?
1,394 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Create the perfect environment for any meeting

You might have a modern environment with all sorts of high-tech equipment, but what makes it worthwhile is how you seamlessly bring together the presentation with audio, video and lighting. The ATEN Control System provides integrated control and system automation.

 

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article provides a convenient collection of links to Microsoft provided Security Patches for operating systems that have reached their End of Life support cycle. Included operating systems covered by this article are Windows XP,  Windows Server…
IF you are either unfamiliar with rootkits, or want to know more about them, read on ....
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

721 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