How to use the :IsFileOpen, IsRegKey, IsRegValue, IsServiceR
Moderator: DosItHelp
How to use the :IsFileOpen, IsRegKey, IsRegValue, IsServiceR
I'm looking for examples on how to use or test the results from the IsFileOpen, IsRegKey, IsRegValue, or IsServiceRunning functions.
mlwhitl,
Yes, I can see it might need some more explanation...
You could check ERRORLEVEL right after calling the function or simply
use the && operator to react on success (service is running) or
use the || operator to react on failure (service not running),
like this:
DOS IT HELP?
Yes, I can see it might need some more explanation...
You could check ERRORLEVEL right after calling the function or simply
use the && operator to react on success (service is running) or
use the || operator to react on failure (service not running),
like this:
Code: Select all
@Echo Off
call:IsServiceRunning "DHCP"&&echo.DHCP service is Running
call:IsServiceRunning "DHCP"||echo.DHCP service is not Running
Goto:Eof
:IsServiceRunning service -- returns success if service is running, otherwise failure
:: -- service [in] - name of the service to check
:$created 20060101 :$changed 20080219 :$categories ServiceControl
:$source http://www.dostips.com
SETLOCAL ENABLEDELAYEDEXPANSION
sc query "%~1"|findstr "STATE.*:.*4.*RUNNING">NUL
EXIT /b
DOS IT HELP?