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

A

anonieko

How can I remotely stop a Windows service, do my stuff, and start the
remote service again.?
You need to have a utility.

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

Visit: http://www.sysinternals.com/Utilities/PsService.html
http://www.sysinternals.com/Utilities/PsTools.html

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top