Search code examples
windowseventsbatch-filetriggersvlc

Run a windows command/script when a specific program opens/closes


Is there a simple way to run a small command or batch script when a specific program opens or closes? I thought there might be a way to make it create a Windows event that I could then use as a trigger in the Task Scheduler, but I couldn't find any events for it.

The program I'm trying to use as a trigger is VLC Media Player.


Solution

  • you could wrap the call to vlc in a batch file:

    call preexec.cmd
    start /b /wait "" vlc.exe
    call postexec.cmd
    

    then just replace the shortcut to start vlc with a shortcut to this batch file. unfortunately this will open a consome window, of course.