Technology Toolbox

Your technology Sherpa for the Microsoft platform

Jeremy Jameson - Founder and Principal



Script to Restart SharePoint 2010 Services

This post originally appeared on my MSDN blog:

Since I no longer work for Microsoft, I have copied it here in case that blog ever goes away.

A couple of years ago, I shared a script (Restart SharePoint Services.cmd) for restarting the various services in Microsoft Office SharePoint Server (MOSS) 2007.

I've since created a new version of the script for use with SharePoint Server 2010. As I mentioned in my previous post, this is primarily intended to be used in development environments whenever you want to simulate a reboot of the server (because this is much faster than actually rebooting). While I certainly hope the memory leaks that often plagued MOSS 2007 solutions are a thing of the past, I still find occasions where I want to quickly stop the various SharePoint services and then restart them.

To do this, I made a copy of the previous script in my SharePoint Toolbox folder, and updated the various service names for SharePoint 2010 (\NotBackedUp\Public\Toolbox\SharePoint\Scripts\Restart SharePoint 2010 Services.cmd):

@echo off

@echo Stopping SharePoint 2010 services...

iisreset /stop /noforce

net stop "SharePoint 2010 User Code Host"

net stop "SharePoint 2010 Timer"

net stop "SharePoint 2010 Administration"

net stop "SharePoint Server Search 14"

net stop "SharePoint Foundation Search V4"

net stop "SharePoint 2010 Tracing"


@echo Starting SharePoint 2010 services...

net start "SharePoint 2010 Tracing"

net start "SharePoint Foundation Search V4"

net start "SharePoint Server Search 14"

net start "SharePoint 2010 Administration"

net start "SharePoint 2010 Timer"

net start "SharePoint 2010 User Code Host"

iisreset /start


Note that I still use a pause statement so that I can optionally perform other tasks while SharePoint is stopped (e.g. detach a content database, move it to a different disk, and then reattach it).

Also note that, depending on your SharePoint configuration, you may see messages about not being able to stop or start various services. For example, I only have SharePoint Server Search currently running in my environment (not SharePoint Foundation Search). Consequently, when I run the script above, I see the following messages when stopping the services:

The SharePoint Foundation Search V4 service is not started.

More help is available by typing NET HELPMSG 3521.

...and the corresponding message when starting the services:

System error 1058 has occurred.

The service cannot be started, either because it is disabled or because it has no enabled devices associated with it.

I suppose the "hip" thing to do would be to upgrade this simple batch file to a PowerShell script and then implement the "smarts" to determine whether the services are actually configured or not (and consequently ignore ones that aren't). Honestly, I just can't justify the effort in doing that given the nature of this script.


No comments posted yet.

Add Comment

Optional, but recommended (especially if you have a Gravatar). Note that your email address will not appear with your comment.
If URL is specified, it will be included as a link with your name.

To prevent spam from being submitted, please select the following fruit: Strawberry

Please add 4 and 8 and type the answer here: