Tuesday, 15 February 2011

batch script get service status -



batch script get service status -

on w7 want receive status of service using psservice, since want on remote computer later.

i seek batch script working on local machine first.

i have 2 issues: first issue "d:/psservice.exe query server" query serviced containing name "server". want query 1 specific service (in illustration named "server".

the other, bigger issue, batch script not working @ all. "dies" (the cmd window closes without execute pause command, create extremely hard debug).

i want store status of service in variable, gonna utilize later compare illustration (if %status% eq "running").

my code far:

for /f token=3 %%i in ('d:/psservice.exe query server 2> nul | find /i "state"') ( set status=%%i ) echo %status% pause

why cmd die , doing wrong?

following work you

@echo off /f "tokens=3 delims=: " %%h in ('d:/psservice.exe query "service" ^| findstr " state"') echo %%h

batch-file

No comments:

Post a Comment