I am running one batch file in loop continuously. While this .bat file is running it should not allow one particular executable to run.

How can this be achieved? Can that particular executable be watched, or can it be detected if has not been clicked, or - if clicked - it should be disallowed from running.

Ultimately, .bat file and particular executable should not run at same time- if .bat file is running it should not executable to run.

  • What OS are you running? - Depending on what version of Windows (7, 8, 8.1, Server 2008, Server 2012 etc.) you can use either Software Restriction Policies or AppLocker - but they need to be at least Enterprise or Ultimate – Kinnectus Aug 10 '15 at 9:15
  • Can you modify the executable? Or is it something supplied as a binary only by a third party? Do you need to actually prevent the program running, or would it be acceptable to replace the entry on the start menu with a program that checks if your batch file is running and only runs the real program if it isn't? – David Richerby Aug 10 '15 at 9:41
  • @big chris, i am running windows 7. – Arjun Aug 10 '15 at 9:49
  • @david, no i cant modify the exe. yes i need to prevent program from running. no, i want it to be checked only by batch file – Arjun Aug 10 '15 at 9:50
  • Which version? My answer (well, part of it) only works on enterprise or Ultimate... – Kinnectus Aug 10 '15 at 9:50

Running a batch file in a continuous loop will not be able to prevent an application from starting. it can be used to see if an application is already running and then kill it. However, if the program you don't want to start starts after your "kill" call (i.e. it runs during your processing portion of your script) then there is no way to monitor this.

You could write a script that loops continuously and only kills the unwanted process - but this is wasteful on processor cycles.

You could write a service that watches for the program to start and then kills it - but you would need, say, Visual Studio (or alternative) and the knowledge to write a Windows Service...

Alternatively, if you have Windows 7 (or higher) Enterprise or Ultimate you could look into using Software Restriction Policies or AppLocker.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.