Skip to main content

I am looking to automate the execution of a .bat file every time I open a specific application, such as notepad.exe, on Windows 10. Here is what I have done so far:

  1. I configured the local security policy to log application starts and stops (Audit process tracking -> Success). This generates an entry in the security event log each time a process starts or ends.

  2. I set up a scheduled task to trigger "on an event." Below is the XML code for the event filter I'm using:

    <QueryList>
       <Query Id="0" Path="Security">
         <Select Path="Security">
           *[System[Provider[@Name='Microsoft-Windows-Security-Auditing'] and Task =
           13312 and (band(Keywords,9007199254740992)) and (EventID=4688)]] and
           *[EventData[Data[@Name='ProcessName'] and
           (Data='C:\Windows\System32\notepad.exe')]]
         </Select>
       </Query>
     </QueryList>
    
    <QueryList>
      <Query Id="0" Path="Security">
        <Select Path="Security">
          *[System[Provider[@Name='Microsoft-Windows-Security-Auditing'] and Task =
          13312 and (band(Keywords,9007199254740992)) and (EventID=4688)]] and
          *[EventData[Data[@Name='ProcessName'] and
          (Data='C:\Windows\System32\notepad.exe')]]
        </Select>
      </Query>
    </QueryList>
    
  3. In the action tab of the scheduled task, I configured it to run the desired .bat file.

However, the scheduled task only triggers the first time I open notepad. I need it to run every time I start notepad.exe. How can I do to trigger the task every time I run notepad.exe?

I am looking to automate the execution of a .bat file every time I open a specific application, such as notepad.exe, on Windows 10. Here is what I have done so far:

  1. I configured the local security policy to log application starts and stops (Audit process tracking -> Success). This generates an entry in the security event log each time a process starts or ends.

  2. I set up a scheduled task to trigger "on an event." Below is the XML code for the event filter I'm using:

    <QueryList>
       <Query Id="0" Path="Security">
         <Select Path="Security">
           *[System[Provider[@Name='Microsoft-Windows-Security-Auditing'] and Task =
           13312 and (band(Keywords,9007199254740992)) and (EventID=4688)]] and
           *[EventData[Data[@Name='ProcessName'] and
           (Data='C:\Windows\System32\notepad.exe')]]
         </Select>
       </Query>
     </QueryList>
    
  3. In the action tab of the scheduled task, I configured it to run the desired .bat file.

However, the scheduled task only triggers the first time I open notepad. I need it to run every time I start notepad.exe. How can I do to trigger the task every time I run notepad.exe?

I am looking to automate the execution of a .bat file every time I open a specific application, such as notepad.exe, on Windows 10. Here is what I have done so far:

  1. I configured the local security policy to log application starts and stops (Audit process tracking -> Success). This generates an entry in the security event log each time a process starts or ends.

  2. I set up a scheduled task to trigger "on an event." Below is the XML code for the event filter I'm using:

    <QueryList>
      <Query Id="0" Path="Security">
        <Select Path="Security">
          *[System[Provider[@Name='Microsoft-Windows-Security-Auditing'] and Task =
          13312 and (band(Keywords,9007199254740992)) and (EventID=4688)]] and
          *[EventData[Data[@Name='ProcessName'] and
          (Data='C:\Windows\System32\notepad.exe')]]
        </Select>
      </Query>
    </QueryList>
    
  3. In the action tab of the scheduled task, I configured it to run the desired .bat file.

However, the scheduled task only triggers the first time I open notepad. I need it to run every time I start notepad.exe. How can I do to trigger the task every time I run notepad.exe?

Source Link
nehalchoy
  • 63
  • 1
  • 1
  • 6

How to automatically run a batch file each time an application opens in Windows 10?

I am looking to automate the execution of a .bat file every time I open a specific application, such as notepad.exe, on Windows 10. Here is what I have done so far:

  1. I configured the local security policy to log application starts and stops (Audit process tracking -> Success). This generates an entry in the security event log each time a process starts or ends.

  2. I set up a scheduled task to trigger "on an event." Below is the XML code for the event filter I'm using:

    <QueryList>
       <Query Id="0" Path="Security">
         <Select Path="Security">
           *[System[Provider[@Name='Microsoft-Windows-Security-Auditing'] and Task =
           13312 and (band(Keywords,9007199254740992)) and (EventID=4688)]] and
           *[EventData[Data[@Name='ProcessName'] and
           (Data='C:\Windows\System32\notepad.exe')]]
         </Select>
       </Query>
     </QueryList>
    
  3. In the action tab of the scheduled task, I configured it to run the desired .bat file.

However, the scheduled task only triggers the first time I open notepad. I need it to run every time I start notepad.exe. How can I do to trigger the task every time I run notepad.exe?