Jump to content
dummzeuch

project.exe is open in another program errors

Recommended Posts

I have been using two tools to add additional data to my executable files in post build scripts for years:

Both tools open the freshly built executable and append chunks of data to it. And both started to fail with the error “[project].exe is open in another program” more often lately.

I never managed to find out exactly what causes the problem. First I suspected BitDefender antivirus, but the error still occurs after I have switched to Windows Defender, so it’s not just BitDefender but probably any antivirus software that is causing the trouble.

As a first try I added a 2 seconds delay between the compiling/linking and the execution of each of these tools. It seemed to help, the errors became much less frequently but they still occurred. Also those 4 seconds always felt like eternity (the whole compile usually takes less than 10 seconds, so 4 additional seconds is a whopping 40%).

So, a few days ago I had enough. I’ve got the source code of these tools, so why not simply add several tries to opening the file? That’s what I did: Both tools now try to open the file and if that fails wait for a second and try again. Rinse and repeat up to 10 times. In my tests, it rarely took more than 2 tries, usually the first one succeeded. That means it shaved these 4 seconds off the build time again with the rare exception of adding them again at very few occasions.

 

Read on (and get download links) in my blog post

https://blog.dummzeuch.de/2019/06/23/project-exe-is-open-in-another-program-errors/

Share this post


Link to post

Would be good to understand the real cause of this behaviour, since I noticed this since Win10 only, and I doubt that AntiVir is the real reason.

I still hope this can be fixed once and forever for any software.

  • Like 1

Share this post


Link to post

All my projects have their DCU and build directories on a RAMdisk and I have specifically excluded this drive in the virus scanner.

 

Using a RAMdisk has the advantage that it increases the lifespan of my SSD drive, my builds are crazy fast and the directory is guaranteed to be empty after each re-boot.

  • Like 1

Share this post


Link to post
2 hours ago, A.M. Hoornweg said:

All my projects have their DCU and build directories on a RAMdisk and I have specifically excluded this drive in the virus scanner.

So, are you seeing the error I described in the blog post?

Share this post


Link to post
On 6/23/2019 at 2:42 AM, dummzeuch said:

I never managed to find out exactly what causes the problem.

Did you try using SysInternals' Process Explorer or Process Monitor tools to see exactly which process(es) have your EXE file open at the time of the error?

 

Share this post


Link to post

No, i have seldom time for deeper investigations.

Usually closing open Apps might help in 80% of the time,

Only sometimes need to Reboot OS.

Since this happens not quite offen indeed, I can live with it.

I only have a feeling that these issues happened in later Win10 versions more offen.

 

Share this post


Link to post
3 hours ago, Rollo62 said:

Only sometimes need to Reboot OS.

Using Process Explorer, you can actually force-close a given handle to a file in any process.  So, if you find an unexpected handle is open to your file, try simply closing it before resorting to a reboot.

Share this post


Link to post

@Remy

Yes, thanks for pushing me in the right direction.
I already tried a "file unlocker" tools, but I found re-boot more clean, also to prevent IDE to get same damage.
Most like this happens in my case during debugging, that some files were not freed from the IDE.
Step 1. close/open IDE fixes this in 50% of the cases

Step 2- reboot fixes the lasat 50%

 

So my rough guess who is blocking the file: 1. IDE,  2. ADB


Unfortunately always when this happens: I am deeply in some urgent, development, debugging tasks, etc., so that searching such remote issue is not my top priority.

But I promise to look after this issue more eager next time when it happens, and to get a note here if I have some findings :classic_wink:

Edited by Rollo62

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×