Restart/Stop/Start Windows Service Remotely – PsService Command

PsTools which is the Windows NT and Windows 2000 Resource Kits come with a number of command-line tools that help you administer your Windows NT/2K systems.

You can download from : https://technet.microsoft.com/en-us/sysinternals/bb896649.aspx

The tools included in the PsTools suite, which are downloadable as a package, are:

  • PsExec – execute processes remotely
  • PsFile – shows files opened remotely
  • PsGetSid – display the SID of a computer or a user
  • PsInfo – list information about a system
  • PsPing – measure network performance
  • PsKill – kill processes by name or process ID
  • PsList – list detailed information about processes
  • PsLoggedOn – see who’s logged on locally and via resource sharing (full source is included)
  • PsLogList – dump event log records
  • PsPasswd – changes account passwords
  • PsService – view and control services
  • PsShutdown – shuts down and optionally reboots a computer
  • PsSuspend – suspends processes
  • PsUptime – shows you how long a system has been running since its last reboot (PsUptime’s functionality has been incorporated into PsInfo)

PsService command is can be used to view and control services remotely.

Usage:

PsService.exe [\\Computer [-u Username [-p Password]]] <cmd> <optns>

Cmd is one of the following:

query     Queries the status of a service

config     Queries the configuration

setconfig Sets the configuration

start     Starts a service

stop       Stops a service

restart   Stops and then restarts a service

pause     Pauses a service

cont       Continues a paused service

depend     Enumerates the services that depend on the one specified

find       Searches for an instance of a service on the network

security   Reports the security permissions assigned to a service

Use the username and password to log into the remote computer in cases where your account does not have permissions to perform the action you specify.

Example:

Below commands run from my computer(ERDALPC). We try to check status and restart w32time service running on SERVER1.

See the service status.

PsService.exe \\SERVER1 query w32time

PsService.exe \\SERVER1 restart w32time