By your own example, you are basing this on your development computer.
Unfortunately, this isn’t the case with publishing. If you were to test the same on a PC that didn’t have anything but the Exe and whatever required library the results would differ.
Also, again, you can rename the exe and get around it yourself.
The proper solution is to build a separate background service that has all the proper layers of access (which can also query program header info, like the title of the window or similar. Which is a lot more relevant than the name of the exe).