@echo off
echo Attempting to stop Clarity Active Directory Synch
for /F "tokens=3 delims=: " %%H in ('sc query "Clarity Active Directory Synch" ^| findstr "        STATE"') do (
  if /I "%%H" EQU "RUNNING" (
   net stop "Clarity Active Directory Synch"
  )
)