Running a script when I exit a program

0

I want to identify when a specific program is being shut down, and run a script when it does.
Is there a way to do that on Windows?

The thing I had in mind is running automated git commit + push commands on my android project, as soon as I exit Android Studio. Is it possible?

Gershon Papi

Posted 2016-01-22T14:05:37.307

Reputation: 143

Answers

1

Don't start Android Studio directly, but start it by command-line example.cmd script:

@echo off
start /W drive:\your\path\to\android_studio.exe
rem git commit + push here

Create/change Android Studio shortcut to execute your script:

cmd /C drive:\your\path\to\example.cmd

g2mk

Posted 2016-01-22T14:05:37.307

Reputation: 1 278

That's awesome, but wouldn't that execute the git commands as soon as android studio is opened, instead when it is closed? – Gershon Papi – 2016-01-23T07:46:48.567

This doesn't seem to work even with the /wait switch, the commands after the start work immediatly after, and not when I close android studio. I tried to do the same with notepad, so it's not an android studio issue. – Gershon Papi – 2016-01-23T08:34:33.167

@GershonPapi I will back on Windows after weekend and will check it... – g2mk – 2016-01-23T11:27:38.047

@GershonPapi /B don't work well with /W... – g2mk – 2016-01-25T15:29:25.203

0

You can write a script as background thread and check whether the process Android Studio there. You can try Python script too but you should NOT use psutil it's resource intensive.

Anti

Posted 2016-01-22T14:05:37.307

Reputation: 11