Become super-efficient at starting & stopping services via scripting

Which would you rather do? Click stop (or start) over and over, while waiting in between the services to make sure everything is up and running ... OR ... click one button and go have lunch?

Service Window vs Batch Script

Honestly I prefer the lunch option. (And for administrators, the quickest option is always the best if you are dealing with restarting services outside of a maintenance period.)

Using some of the information I posted previously on I developed the following scripts to either start or stop the services. This works pretty darn well on my Windows7 machine.

To get these scripts working in your windows environment, modify the "Service Name" to exactly what your service is called. (I always open the service from the Service Manager, then copy the name from the properties.) If you are still on 9.2, just remove the SAS Framework Data Server line. Also, I would recommend tweaking the timeout amounts (which creates a specified delay in seconds) to fit your system. My guess is that your server is much faster than my laptop.

Note that for you UNIX/etc users out there, a sh script is the ticket.

Start Script for 9.3

sc start "SAS [EBIServer93-Lev1] SASMeta - Metadata Server"
timeout 10
sc start "SAS [EBIServer93-Lev1] Object Spawner"
timeout 5
sc start "SAS [EBIServer93-Lev1] FrameworkServer - SAS Framework Data Server"
timeout 5
sc start "SAS [EBIServer93-Lev1] Remote Services"
timeout 15
sc start "JBoss - SASServer1"

Stop Script for 9.3

sc stop "JBoss - SASServer1"
timeout 400
sc stop "SAS [EBIServer93-Lev1] Remote Services"
timeout 30
sc stop "SAS [EBIServer93-Lev1] FrameworkServer - SAS Framework Data Server"
sc stop "SAS [EBIServer93-Lev1] Object Spawner"
timeout 10
sc stop "SAS [EBIServer93-Lev1] SASMeta - Metadata Server"

One Comment

  1. Posted October 21, 2011 at 8:58 am | Permalink

    Hi Angela,

    Great post! This scripting technique you describe for service start/stops can be especially handy when you have multiple SAS services spread over multiple machines. A nice thing about SC is that it can also be used to start/stop services on a different machine such as:

    sc start \\mysascomputeserver "SAS [EBIServer93-Lev1] Object Spawner"

    As an alternative to tuning sleep times, SC can also be used to iteratively poll the service state. I found out about this when I stumbled on some scripts that a nice fellow posted in answer to someone's stackoverflow question:


  • About this blog

    Angela Hall manages a team of SAS Fraud Framework implementers within the SAS Solutions On-Demand organization. Angela is co-author of the book Building Business Intelligence using SAS: Content Development Examples and The 50 Keys to Learning SAS Stored Processes
    BI Bible Book 50 Keys to STP Book
  • Subscribe to this blog

    Enter your email address:

    Other subscription options

  • Archives