Geeks With Blogs
kazim mehdi

I have to update the windows service.exe and related dll by using console on remote computer.


I tried


net start <servicename>



but it not allowed to query or issue command on the remote computer.


then I tried sc & PsService from SysInternals.


sc \\<ServerName> stop <ServiceName>


PsService \\<ServerName> stop <ServiceName>
the problem is both of them issue stop command and returned the control but I want to sure that service is stopped completely so that 
I can update files.
I write the following code to do that.
@echo off
set serverName=server1
set serviceName=ervice1
sc \\%serverName% stop %serviceName%

call:check %serviceName%

echo the service %serviceName% on servcer:%serverName% is :stopped

echo serverName: %serverName%
echo seriveName %~1

sc \\%serverName% query %~1 | find /I "State" | find /I "STOPPED"
goto:check %~1
) else (
Posted on Monday, August 1, 2011 11:55 AM Windows | Back to top

Comments on this post: Stop/Start windows service remotely. Wait till it stops completely

No comments posted yet.
Your comment:
 (will show your gravatar)

Copyright © kazim sardar mehdi | Powered by: | Join free