EMEA Data Loss Prevention User Group

 View Only
Expand all | Collapse all

Need help to create a .bat or cmd script that check edpa service

Jump to Best Answer
  • 1.  Need help to create a .bat or cmd script that check edpa service

    Broadcom Employee
    Posted Jul 08, 2015 08:17 AM

    Hi Everyone,

     

    Could you guys help me? I Need help to create a .bat or cmd script that:


    1. check if the service is running edpa.exe
    2. if so, does not install the agent
    3. if not, run the agent installation script

     

    The purpose is to add this at a script logon at machines.

     

    Does anyboby already made it? or Know how to write ir?

     

    Thank you so much!

    Best Regards!

     



  • 2.  RE: Need help to create a .bat or cmd script that check edpa service
    Best Answer

    Trusted Advisor
    Posted Jul 09, 2015 07:03 PM

    Lopes,

    Here is how to see if a process is running..there are a few ways fo doing this..

    tasklist /FI "IMAGENAME eq myapp.exe" 2>NUL | find /I /N "myapp.exe">NUL
    if "%ERRORLEVEL%"=="0" echo Programm is running
    tasklist /FI "IMAGENAME eq notepad.exe" /FO CSV > search.log
    
    FOR /F %%A IN (search.log) DO IF %%~zA EQU 0 GOTO end
    
    start notepad.exe

     

    @echo off
    set EXEC_CMD="rsync.exe"
    wmic process where (name=%EXEC_CMD%) get commandline | findstr /i %EXEC_CMD%> NUL
    if errorlevel 1 (
        %EXEC_CMD% ...
    ) else (
        @echo not starting %EXEC_CMD%: already running.
    )