I had VS Code on my Windows laptop, but it wasn’t launching. I tried uninstalling it and reinstalling it, but I kept receiving this error message: "An error occured while trying to replace the existing file: DeleteFile failed; code 5. Access is denied". Does anyone know how to resolve it? I’m using a .exe file to set it up.
I tried uninstalling it and reinstalling, but it gave the same error message. I’ve also deleted all the VS Code related files I could find.
2
Answers
Googling "
github vscode issues "An error occurred while trying to replace the existing file" "DeleteFile failed" "code 5"
", I found the following:Failed to update from 0.10.2 to 0.10.3 on Windows 10
#895. An issue someone encountered while trying to apply updates. It was closed by the issue-ticket creator, since they found that they could work around the issue by restarting before trying to apply the update.
Failed to update: An error occurred while trying to replace the existing file, DeleteFile failed; code 5, Access is denied.
#146538. Also an issue with applying updates. A VS Code maintainer (João Moreno) commented that "it is indeed related to Antivirus or similar software keeping a handle on Code.exe or other core files.", and suggested as a workaround to "disable Windows background updates by setting
update.enableWindowsBackgroundUpdates
tofalse
". This issue ticket was closed as a duplicate of Windows update failed: Access is denied #47841, which at the time of this writing is still open, but locked.In that issue ticket, users have reported that they only encounter that issue with user installations and not system installations. One user commented that they "need to download the new installer from the website, reboot, and install it first thing for it to succeed".
The error message you are encountering ("DeleteFile failed; code 5. Access is denied") suggests that the installer is unable to delete some existing files during the installation process. This might be due to permissions issues or other processes locking the files.
Here are some steps you can try to resolve the issue:
->Run the installer as an administrator:
Right-click on the VS Code .exe file and select "Run as administrator." This will give the installer the necessary permissions to modify files on your system.
->Check for running processes:
Make sure that all instances of Visual Studio Code and related processes are closed before attempting the installation. Sometimes, background processes may keep files locked, preventing deletion during the installation.
->Use a different installer:
If the .exe installer continues to fail, try using the .zip package instead. The .zip package allows you to install VS Code without using an installer and might bypass the issue with file deletion.
->Check your antivirus/firewall software:
Some antivirus or firewall programs may interfere with the installation process. Temporarily disabling these security software or adding an exception for the VS Code installation may help.
->Clean up temporary files:
Sometimes, temporary files left behind from previous installations can cause conflicts. Use the Disk Cleanup utility on Windows to remove temporary files and try reinstalling again.
->Use a third-party uninstaller tool:
If you haven’t completely removed all VS Code related files, using a third-party uninstaller tool like "Revo Uninstaller" can help ensure a thorough removal before attempting a fresh installation.
->Check Windows permissions:
Ensure that your user account has sufficient permissions to install software on your system. If you are using a managed computer, you may need to contact your system administrator for assistance.