Underc0de

Programación Scripting => Batch - Bash => Mensaje iniciado por: ANTRAX en Julio 18, 2011, 09:35:37 PM

Título: Funciones de Comprobaciones
Publicado por: ANTRAX en Julio 18, 2011, 09:35:37 PM
Funcion, averiguar si un servicio esta corriendo:

Código (dos) [Seleccionar]
:: Autor ne0x
:: Sintaxis:

:: call:svc nombre variable
:: nombre Nombre del servicio a chequear
:: variable Nombre de la variable en la que se pondra la respuesta en dato boleano

:svc
net start | find "%~1" > nul
if %errorlevel%==0 (
set %2=0
  ) ELSE (
set %2=1
)
goto:EOF


Funcion, averiguar si se ha iniciado un proceso:

Código (dos) [Seleccionar]

:: Autor ne0x
:: Sintaxis

:: call:pr nombre variable
:: nombre Nombre del proceso a chequear
:: variable Nombre de la variable en la que se guardara la respuesta en tipo boleano.

:pr
taskklist | find "%~1"
if %errorlevel%==0 (
set %2=0
  ) ELSE (
set %2=1
)
goto:EOF