Run a bat file when a specific application is opened in Windows XP

537 Views Asked by At

I want to know how can we run a bat file when a specific application is opened?

Eg: I would like to run a bat file whenever mspaint is opened.

I have successfully performed this in Windows 7 and Windows 10 using Task Scheduler. But the task scheduler available in Win Xp is very basic.

1

There are 1 best solutions below

3
Vahid Asbaghi On

You could use another batch file that runs on startup of windows. use while loop with an appropriate sleep to detect when Paint.exe runs.
then you could write more commands to do anything you want. For example, as you said, you could run another batch file...
I found this solution by an investigation of these topics:

Syntax for a single-line Bash infinite while loop
How to check if a process is running via a batch script
Batch program to to check if process exists