How can I remotely stop Windows service, do some stuff, and start the remove service again.

How can I remotely stop Windows service, do some stuff, and start the remove service again.

Post by anoniek » Sat, 29 Oct 2005 08:35:34


How can I remotely stop a Windows service, do my stuff, and start the
remote service again.?


1. First download the utility psservice.exe
from pstools package of SysInternals site

Visit: http://www.yqcomputer.com/
http://www.yqcomputer.com/

Run a batch file that loops until the service is stopped
do your process and start the service again



2. Assuming the naem of remote machine is MACHINE_ABC
and the windows service is MyWindowService


Here is the batch file:
-----------------------------------------------------

:start
psservice.exe \\MACHINE_ABC stop MyWindowService
if errorlevel 1 goto :start

rem -----------------------------------
rem do your stuff here
rem -----------------------------------


if errorlevel 1 goto :start
:restart
psservice.exe \\MACHINE_ABC start MyWindowService
if errorlevel 1 goto :restart