Linker Tools Error LNK1168, cannot open filename.exe for writing

There is one thing driving me crazy whenever I compile a cpp program:

Linker Tools Error LNK1168, cannot open filname.exe for writing

This error occurs everyday.

I was able to realize that this problem occurred because the exe file was not finished even after I stop my debugging.

What I tried to solve this problem:

  1. On task manager, I tried to end the process ( which is in my case, Samsung2.exe ) but however I click that, there is no response.

  2. the below paragraph is from

https://docs.microsoft.com/en-us/cpp/error-messages/tool-errors/linker-tools-error-lnk1168?f1url=https%3A%2F%2Fmsdn.microsoft.com%2Fquery%2Fdev15.query%3FappId%3DDev15IDEF1%26l%3DEN-US%26k%3Dk(LNK1168)%26rd%3Dtrue

""" If your executable can’t be overwritten by the build process, it may be locked by File Explorer. If the Application Experience service has been disabled, File Explorer may hold on to an executable file handle lock for an extended time. To fix this issue, run services.msc and then open the Properties dialog box for the Application Experience service. Change the Startup type from Disabled to Manual. """

There is no Application Experience service (on windows 10 )

  1. I downloaded 'Process Explorer' and tried to kill my process.

but only error message pops up ( " access is denied " )

enter image description here

It is shortening my life. Can you help me?

FYI, I'm using Visual Studio 2017 and Windows 10(64 bits)

1 answer

  • answered 2018-07-11 07:05 ZDF

    Not an answer, but too long for a comment.

    The snapshot in your question shows the processes (parents & children), not the handles.

    To find who is blocking your file:

    1. Ctrl + F | Enter your executable name | Search | Wait
    2. Select the founded process.
    3. Ctrl +L
    4. Look for your file in the lower pane.

    To close the handle: Right click the file | Close Handle

    From my experience, sometimes the debugger does not end gracefully and keeps the file locked. The only solution that works for me is to close/kill VS or restart the computer. If the project is saved on Dropbox (or similar), the files might be locked while the synchronization is done and you get similar errors. The MS antivirus is smart enough not to interfere and so are most AVs.

    enter image description here