I occasionally find myself starting and stopping multiple windows services. The only tool I'm aware of for stopping and starting windows services is the "Services" program under "Administrative Tools" (%SystemRoot%\system32\services.msc /s). This program seems to only allow you to manipulate one service at a time, often pausing while it waits for the service to stop. There is a "Close" button available, but I'd prefer to just select all the services I want to stop or start, and perform a single command on all of them at one time.
Is there an easier way to start and stop multiple windows services for Windows XP?
Use the "net start" and "net stop" commands in your cmd.exe to start and stop a service:
net start "Service name with space"
net stop SerivceNameWithoutSpace
Be aware that you will need quotes if the service name has spaces.
It possible to start/stop Windows services by using command-line tools such as net start and net stop and sc.exe, but as far as I known none of them allows to operate on more than one service at once.
The easiest solution is to invoke the command-line tool multiple times by specifying different service names in a batch file.
Also, note that the reason why there is a delay between issuing a stop command to a Windows Service and the time when the process actually exits, is due to the fact that the Windows Service Controller waits up to 30 seconds to allow services to shutdown properly.If a service doesn't exit by that time, a message will inform you that "the service didn't respond in a timely fashion". More details can be found here.
You could use powershell.
Something like :
get-service -displayname SQL | stop-service
This stops all services with SQL in their display name.
http://www.microsoft.com/technet/scriptcenter/topics/msh/cmdlets/stop-service.mspx
What about the command line?
The net start and net stop commands are where you're going...
Try msconfig (go to the "Run" dialog, type "msconfig"). Choose the "services" tab.
You could write a command/batch script that uses the command-line service controller, sc.exe.
Alternatively, you could check out the SysInternals psservice.exe command-line tool.
Related
I have looked for a bit on Stack Overflow for a way to have a container start up and wait for an external connection but have not seen anything.
Here is what my process looks like currently:
Non-Docker external process reaches out at X interval and tells system to run a command.
Command runs.
System should remain idle until the next interval.
Now I have seen a few options with --wait or sleep but I would think that would not allow the container to receive the connection.
I also looked at the wait for container script that is often recommended but in this case I need the container to wait for a script to call it on non defined intervals.
I have tried having this just run the help command for my process but it then fails the container after a bit of time and makes it a mess for finding anything.
Additionally I have tried to have the container start with no command just to run the base OS and wait for the call but that did not work either.
I was looking at this wrong.
Ended up just running like any other webserver and database server.
I am writing a jmeter script to perform DB functional testing. I have a Windows Service that runs every on X interval and it updates certain DB records when its done. I need to be able to run the windows service remotely and verify the DB changes.
Is it possible to run a windows service remotely say using sc \\machine stop <service> from jmeter?
If yes, how can I do this?
Appreciate any suggestions!
Look into OS Process Sampler.
For command like sc SERVER_NAME stop SERVICE_NAME it will be configured like:
For a service written in c#.
We have it set to auto-restart so if it crashes it will restart itself.
This is fine, but we also want a way to force stop the service (the service could be deadlocked). This would happen once a week before taking a database backup.
If we use "net stop" the service might not shut down.
If we do a taskkill this will kill the service but then it will start up again in one minute.
Any ideas on how to get both use cases working?
We want to auto-restart if the service crashes, and we want to be able to run an unattended process that will stop the service (no matter what), take a backup of the database, and then restart the service after that.
http://www.codeproject.com/Articles/31688/Using-the-ServiceController-in-C-to-stop-and-start
You need to add a library, then it's just:
service.Stop() and service.Start()
As Part of setting up continuous integration using bitten, I would like to set up some bitten-slaves on windows. However, bitten documentation lacks instructions on how to register bitten slave as a service.
Looking at Microsoft's documentation on How to create a Windows service by using Sc.exe, I've tried the following:
sc create bitten-slave binPath= "C:\Python26\Scripts\bitten-slave.exe --verbose
--log=C:\dev\bitten.log http://svn/cgi-bin/trac.cgi/builds"
The service was indeed created. But trying to start it, I get the following error:
The bitten-slave service failed to
start due to the following error: The
service did not respond to the start
or control request in a timely
fashion.
What am I doing wrong?
Any random program can't run as a service in Windows, the application needs to be specially written to talk to the service controller.
An application that wants to be a service needs to first be written in such a way that it can handle start, stop, and pause messages from the Service Control Manager.
However, Microsoft does provide a generic service wrapper, SRVANY, which can be used to run an arbitrary program as a service. I use SRVANY to run several python scripts as services, so it should work properly.
This page on the Bitten wiki describes a simple Python script that can be configured as a scheduled task to ensure the Bitten slave is kept running.
I have five Windows services that all exist in the same exe. Is there a way to tell Windows to run each service as it's own process?
Yes. See the CreateService API
Note the SERVICE_WIN32_OWN_PROCESS flag.
Couldn't you use background worker threads?