Simplest way to restart service on a remote computer

T - M picture T - M · Nov 5, 2008 · Viewed 229.9k times · Source

What's the easiest programmatic way to restart a service on a remote Windows system? Language or method doesn't matter as long as it doesn't require human interaction.

Answer

Tomalak picture Tomalak · Nov 5, 2008

As of Windows XP, you can use sc.exe to interact with local and remote services. Schedule a task to run a batch file similar to this:

sc \\server stop service
sc \\server start service

Make sure the task runs under a user account privileged on the target server.

psservice.exe from the Sysinternals PSTools would also be doing the job:

psservice \\server restart service