How to start a program when another one is started

14

12

I want a program to start each time another one is starting.

Here's an example: Each time I start Google Chrome, I would like iTunes to start at the same time.

Also, I want it to start when I click a link in my browser that starts a program (like "view in iTunes on the iTune website).

I do not want to have to do with a .bat file.

I am running on Windows 7

TheBird956

Posted 2014-04-23T23:33:25.103

Reputation: 275

Can you clarify. The first option is that if you open Chrome, itunes starts too. But the second option - when you click a link that opens itunes, you want something else to open as well? – Paul – 2014-04-23T23:40:38.290

Those are just examples, basically I want to start mutiple programs when I want to start one or another program wants to start it – TheBird956 – 2014-04-23T23:45:42.453

Answers

19

You could probably set up specific pairs of apps to run using the registry, and altering what deals with mimetypes. However another more generic way, and far more complex, is to use the Task Scheduler. The task scheduler can start an app based various types of triggers, including Event Log entries.

So all we need is to ensure an event is created whenever an application starts, and then create a scheduled task to start whenever the event is logged.

Enable 'application start' logging

  1. Start and enter secpol.msc into the Run box
  2. Navigate to Local Policies/Audit Policy
  3. Double Click Audit process tracking and enable Success

Now, if you start any application, if you look in Event Viewer / Security Log you will see a Process Creation event 4688 each time an application is started.

Create scheduled task based on trigger

  1. Open Task Scheduler and create a new task
  2. On the General Tab, give the task a name
  3. On the Triggers tab, create a new trigger, and choose On an event as the trigger
  4. Choose Custom, and click Edit Event Filter
  5. Change the Filter settings as follows:

Task filter

Now Switch to the XML tab, and enable edit query manually

You will see the following

<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)]] 
    </Select>
  </Query>
</QueryList>

Now you just need to add the application you want to cause the trigger. For example, this one uses notepad.exe as the trigger:

<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='NewProcessName'] and (Data='C:\Windows\System32\notepad.exe')]]
    </Select>
  </Query>
</QueryList>

Click Ok for this, then Ok to close the trigger dialog box.

Now choose the Action tab, and create a new action, that is Start a Program, and browse to the app you want to start along with the trigger application.

Paul

Posted 2014-04-23T23:33:25.103

Reputation: 52 173

@TheBird956 Did you manage to get it to work? – Paul – 2014-07-03T08:09:27.297

I do not have the correct windows version. I think I need Pro to do that, but I tried on my brother's computer who has Pro installed and it works. – TheBird956 – 2014-07-03T22:44:40.103

1To set the trigger to program/process exit/termination/close instead of start/create, this XML for the event filter worked for me:

`<QueryList>

<Query Id="0" Path="Security"> <Select Path="Security"> *[System[Provider[@Name='Microsoft-Windows-Security-Auditing'] and (band(Keywords,9007199254740992)) and (EventID=4689)]] and *[EventData[(Data='PATH TO THE DESIRED EXE')]] </Select> </Query> </QueryList>` – V. Rubinetti – 2017-10-25T21:47:51.013

I always get An event filter for a trigger is not valid error when pressing OK at the end of the task creation. However the event filter looks exactly like yours (I generated it myself) with the exception that my program sits in the Program Files (x86) folder. – alexlomba87 – 2019-06-06T19:41:47.230

Thanks, great answer. I was using Sysmon before but it's way more involved. You can skip all of step five and just go to the manual route: Now Switch to the XML tab, and enable edit query manually and then use the code you've pasted as an example. – Ste – 2019-10-27T18:50:57.300

I dont have anything named secpol.msc. I made a small reserach and I think its because it is not available in Windows 7 Home Premium. Is there another way? – TheBird956 – 2014-04-24T02:30:44.427

The audit policy needs to be changed for this to work, and it is absent from W7HP. There are a few guides out there for installing gpedit.msc on W7HP which you might want to try. You can edit the audit policy with this too, in Computer Configuration/Windows Settings/Security Settings/Audit Policy – Paul – 2014-04-24T03:19:38.460

0

I am sure that Paul's answer above might work for most of people, however for some reason I could not get it to work with my program.

When specifying the path for Notepad.exe, the Task was created successfully; when I changed the path to the one of the program I was intending to use, I always got An event filter for a trigger is not valid error when pressing OK at the end of the task creation. Consider that the event filter looks exactly like Paul's (I generated it myself following his procedure) with the exception that my program sitted in the Program Files (x86) folder.

I eventually solved my problem by installing an external software, Bill's Process Manager. Kudos to this StackExchange answer for it.

alexlomba87

Posted 2014-04-23T23:33:25.103

Reputation: 111