Why is ShellExecuteEx failing with SE_ERR_NOASSOC for an EXE file?
I have a C application that does the following on Windows 2016 Server...
- It creates a new folder
- It copies an EXE file to the new folder (this copied EXE is also a C application)
- It runs the copied EXE using ShellExecuteEx
This process works 95% of the time but 5% of the time ShellExecuteEx fails with SE_ERR_NOASSOC (#31).
The application performs a few retries with a 30 second delay between each retry but ShellExecuteEx still fails with SE_ERR_NOASSOC.
Only after a FEW MINUTES does ShellExecuteEx work ok and run the EXE.
I have checked on-line for ShellExecuteEx and SE_ERR_NOASSOC issues but there is nothing related to EXE files.
I do not understand how it is even possible to get an SE_ERR_NOASSOC (ie. file association error) on an EXE file since it really does not have or need an association.
I thought that maybe Windows Defender was temporarily quarantining the recently copied EXE file until it has been scanned but I would expect a different error such as ERROR_FILE_NOT_FOUND or SE_ERR_ACCESSDENIED, but certainly note SE_ERR_NOASSOC.
Any assistance debugging this strange issue would be appreciated!