Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Detect a Program Has Started  (Read 2702 times)

0 Members and 1 Guest are viewing this topic.

revengexx14

    Topic Starter


    Starter

    Detect a Program Has Started
    « on: November 12, 2008, 06:34:52 PM »
    Is there a DOS command that detects if a program has started?

    I'm attempting to perfect a program that automatically closes Internet Explorer whenever it opens. This isn't for harmful use, don't worry. I use Mozilla Firefox, and get sick of spyware that I can't seem to delete opening up Internet Explorer.

    Anyway, so far I have this:

    Code: [Select]
    @ECHO OFF
    :start
    tskill iexplore
    ping localhost -n 5 >nul
    CLS
    ping localhost -n 10 >nul
    GOTO start

    As you can see, it has to work fairly frequently to be effective. If anyone has a code that detects when a program initiates, please post it here.

    Many thanks,

    -Jake

    Note: Not sure if this makes a difference, but I have this set up so that it doesn't open a visible window while its running.
    « Last Edit: November 12, 2008, 06:47:17 PM by revengexx14 »

    revengexx14

      Topic Starter


      Starter

      Re: Detect a Program Has Started
      « Reply #1 on: November 12, 2008, 06:59:41 PM »
      I'm thinking something along the lines of using the "IF" command to detect if Internet Explorer is running, and then terminating it.

      So how can I make it look for the iexplore.exe process?

      Dark Blade

      • Forum Gaming Master


      • Adviser

        Thanked: 24
        • Yes
      • Experience: Experienced
      • OS: Windows XP
      Re: Detect a Program Has Started
      « Reply #2 on: November 12, 2008, 07:57:19 PM »
      Use tasklist


      TASKLIST [/S system [/U username [/P [password]]]]
               [/M [module] | /SVC | /V] [/FI filter] [/FO format] [/NH]

      Description:
          This command line tool displays a list of application(s) and
          associated task(s)/process(es) currently running on either a local or
          remote system.

      Parameter List:
         /S     system           Specifies the remote system to connect to.

         /U     [domain\]user    Specifies the user context under which
                                 the command should execute.

         /P     [password]       Specifies the password for the given
                                 user context. Prompts for input if omitted.

         /M     [module]         Lists all tasks that have DLL modules loaded
                                 in them that match the given pattern name.
                                 If the module name is not specified,
                                 displays all modules loaded by each task.

         /SVC                    Displays services in each process.

         /V                      Specifies that the verbose information
                                 is to be displayed.

         /FI    filter           Displays a set of tasks that match a
                                 given criteria specified by the filter.

         /FO    format           Specifies the output format.
                                 Valid values: "TABLE", "LIST", "CSV".

         /NH                     Specifies that the "Column Header" should
                                 not be displayed in the output.
                                 Valid only for "TABLE" and "CSV" formats.

         /?                      Displays this help/usage.

      Filters:
          Filter Name     Valid Operators           Valid Value(s)
          -----------     ---------------           --------------
          STATUS          eq, ne                    RUNNING | NOT RESPONDING
          IMAGENAME       eq, ne                    Image name
          PID             eq, ne, gt, lt, ge, le    PID value
          SESSION         eq, ne, gt, lt, ge, le    Session number
          SESSIONNAME     eq, ne                    Session name
          CPUTIME         eq, ne, gt, lt, ge, le    CPU time in the format
                                                    of hh:mm:ss.
                                                    hh - hours,
                                                    mm - minutes, ss - seconds
          MEMUSAGE        eq, ne, gt, lt, ge, le    Memory usage in KB
          USERNAME        eq, ne                    User name in [domain\]user
                                                    format
          SERVICES        eq, ne                    Service name
          WINDOWTITLE     eq, ne                    Window title
          MODULES         eq, ne                    DLL name

      Examples:
          TASKLIST
          TASKLIST /M
          TASKLIST /V
          TASKLIST /SVC
          TASKLIST /M wbem*
          TASKLIST /S system /FO LIST
          TASKLIST /S system /U domain\username /FO CSV /NH
          TASKLIST /S system /U username /P password /FO TABLE /NH
          TASKLIST /FI "USERNAME ne NT AUTHORITY\SYSTEM" /FI "STATUS eq running"


      If you need more specific help, I'll give it later. But I'm at school right now.