Process Persistence-Need Help


  1. Posts : 1
    a
       #1

    Process Persistence-Need Help


    Hello,

    I am trying to design a simple antivirus, and I am at the point where i am creating a batch file that will make sure the Antivirus scanner is running. Here's my plan:
    1. Batch file in startup folder with a loop function
    2. Said batch file does a tasklist command and searches for the name of the file on the running processes
    3. If it finds the process running it does nothing
    4. If it does not see the process running, it simply starts it again
    It is very simple design but I am running into trouble when i am writing the code. My question is: How do I write this idea into a command? The idea being how the if statement factors into the tasklist command. So I need the tasklist command to be filtered to see if the process is running based on the name, and then I need to set the output of the tasklist command as a variable so that I can write the if statement: if %process%==Client.exe (goto yes)
      My Computer


  2. Posts : 1,049
    Windows 7 Pro 32
       #2

    Hi and welcome to SevenForums!

    Here's one example
    Code:
    set PROCESS=
    for /f %%A in ('tasklist ^| find "Client.exe"') do set PROCESS=%%A
    IF "%PROCESS%" == "" GOTO NOTRUNNING
    ECHO Process running!
    GOTO DONE
    
    :NOTRUNNING
    ECHO Process NOT running!
    
    :DONE
    The output from tasklist is filtered with the find command to search for your process. If the process wasn't found the PROCESS variable will be empty. The value for PROCESS variable is irrelevant and will contain more information than just the process name. But if the variable isn't empty then it means the process was found in the tasklist.
    That should work :)
      My Computer


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 08:50.
Find Us