Warning when starting an app [windows automation]

2

I have two . exe application that conflict eachother ( App_A and App_B). I want to warn the user when he launch App_B if App_A is already running.

ps: the warning message must really open before App_B launch, not 1 sec after. The message warning would be :

Are you sure you want to launch App_B ? App_A is already running! Yes/ No

The user can try to launch App_B either from desktop shortcut of from a associated file. (user click on the file and it auto-launch App_B to edit the file.)

App_A and App_B aren't my software, I can't edit them. I think I must use an external automation software.

Does somebody have any idea on which software I could use ? I have tried Window scheduler with batch file (no sucess), but I am open to any other solution. I have tried with automation tool like Eventghost with no sucess

n0tis

Posted 2015-12-23T15:16:09.090

Reputation: 123

I'm guessing these aren't programs you have access to the source code for? Mutex's could be used to this effect. Otherwise you could create a batch file to do so, something like this but using the CHOICE command.

– Jonno – 2015-12-23T15:20:43.790

no I don't have source. the problem with batch is this : if user double-click on a default-binded file, window will open App_B and not the batch script, so the batch solution would be bypassed – n0tis – 2015-12-23T15:21:49.720

I can't really see any way around that, other than to not allow people to open file types associated with the application and force them to open it via a batch. – Jonno – 2015-12-23T15:24:10.993

@RogUE I think the OP means that they want to retain the functionality to open associated file types (EG, if you open a .xls file it'll open through Excel). This would bypass this entirely, although I might have misinterpreted this? – Jonno – 2015-12-23T15:37:27.927

@Jonno You are right. I should have used the term file-assiciation, I will edit – n0tis – 2015-12-23T15:46:22.427

Answers

2

Something to try:

Example batch file (obviously untested ;) ):

@echo off
REM Check for process
tasklist /fi "Imagename eq App_A.exe" 2>NUL | find /i /n "App_A.exe">NUL
REM If it isn't found (errorlevel > 0) launch App_B
if %ERRORLEVEL% GTR 0 goto LaunchB

REM Otherwise (errorlevel 0) it's been found, so ask for confirmation...
choice /C YN /M "App_A is running, continue launching App_B?"
if %ERRORLEVEL% EQU 1 goto LaunchB
if %ERRORLEVEL% GTR 1 exit

:LaunchB
App_B2.exe %1 %2 %3 %4 %5

Ƭᴇcʜιᴇ007

Posted 2015-12-23T15:16:09.090

Reputation: 103 763

Thank you ! The batch work perfectly :D. However I have some problem to compile it to exe: I have tried with this tool http://www.battoexeconverter.com/ but then the exe say "attrib" doesn't exist, then I tried with this tool : http://www.f2ko.de/en/b2e.php, but here the exe simply output the third line of your script, without doing anything else... It's like some of this complex scipt isn't supported by exe compilator. Any Idea ?

– n0tis – 2015-12-23T17:34:29.890

I converted that example batch using the tool from battoexeconverter.com without problem, and it works as expected. Perhaps create a new question about the problem converting your batch to an EXE with that tool, and include the exact code you are trying to convert, as well as the exact error message(s) you receive when you try to run it. – Ƭᴇcʜιᴇ007 – 2015-12-23T18:05:48.037

okay I will do that, thanks again for your code – n0tis – 2015-12-23T18:09:05.480