32

Wanted to add this question to the pool in case someone has the same problem

I was unable to update Visual Studio 2017 on Windows 7 and got the following error:

Unable to install the files to target location. Error: The folder 'c:\Program Files (x86)\Microsoft Visual Studio\Installer' or a file within it is locked by another program. Close any applications that might be using it and try again.

Vivek Nuna
  • 25,472
  • 25
  • 109
  • 197
Janspeed
  • 2,644
  • 2
  • 22
  • 22
  • 3
    And for the simplest solution-- don't forget to just try rebooting your computer, that might solve it. Worked for me anyway – ocean800 Apr 30 '20 at 22:50

12 Answers12

88

The initial solution I found was to reinstall Visual Studio but felt that it might be unnecessary. The solution I found was to close down Visual Studio, go to

C:\Program Files (x86)\Microsoft Visual Studio\Installer

and rename the folder "Installer" to something else, then run vs_installer.exe from the renamed folder.

Hope that helps someone.

Mustafa Özçetin
  • 1,893
  • 1
  • 14
  • 16
Janspeed
  • 2,644
  • 2
  • 22
  • 22
  • 1
    This worked for me, thanks. First time I've had this issue, when updating from VS2017 15.7.1 to 15.7.2. Should you rename the Installer folder back to its original name after doing this, or is it ok to leave it under its new name? – Daren May 23 '18 at 08:06
  • 3
    This was a while ago but I think it recreated the folder and content. It has worked for me ever since without me having to move contents or rename it back. I think I even deleted the renamed folder after use. – Janspeed May 23 '18 at 08:11
  • 1
    Thanks it worked, vs2019 preview 1.0 version have same installer bug (not fixed yet) – sailfish009 Feb 03 '19 at 03:03
  • 2
    Had to do this again today (vs2019, updating to version 16.2.3). Thanks! – Michael Armes Aug 22 '19 at 14:08
  • 4
    I faced the same issue trying to install `msvs 2019 16.3.0` update. I can't rename `Installer` folder: `The action can't be completed because the folder or a file in it is open in another program`. Using `Resource monitor` I haven't found any process which uses something from this folder – mtkachenko Sep 24 '19 at 07:52
  • 1
    No can do. Can't rename folder because file is open! – Mike Lowery May 21 '20 at 18:53
  • 4
    Same problem almost 4 years later. Good job microsoft. At the very least they could state what the problem is inside error message. – Eternal21 Mar 24 '21 at 20:40
21

I just recently encountered the same error while trying to update the Visual Studio 2017 installer on Windows 10. In my case, the c:\Program Files (x86)\Microsoft Visual Studio\Installer directory was locked because of virus/malware scanning software running in the background. After stopping that, the installation of the VS 2017 installer had no more problems.

What initially misled me about the source of the problem was that the process which had a lock on the files in that directory was the special System process in Process Explorer, so I was initially going down the wrong rabbit hole.

porcus
  • 823
  • 8
  • 11
  • 20
    Malwarebytes was the culprit for me. – Tom May 22 '18 at 18:27
  • 2
    This worked for me as well. I tried to add c:\Program Files (x86)\Microsoft Visual Studio to exclusion folder in malwarebytes with no luck. I had to disable all protection options in dashboard, after that it worked like a charm. – BNebula Jul 08 '18 at 19:36
  • 1
    Excluding the `c:\Program Files (x86)\Microsoft Visual Studio\Installer` folder worked for me: VS2017 15.7.5 update, Windows 10/64bit 2016 LTSB, Malwarebytes 3.5.1.2522 – gridtrak Jul 11 '18 at 13:24
  • 1
    I also had to run Visual Studio and its update installer "as Administrator" after disabling Malwarebytes like BNebula described. The exclusions were not enough. Maybe need to exclude `ProgramData\Microsoft\VisualStudio\Packages` too ? – gridtrak Jul 11 '18 at 14:06
  • 1
    same thing with malware analysis tool. – HolloW Oct 01 '18 at 02:55
7

If you have malwarebytes then you can add to the allow list C:\Program Files(x86)\Microsoft Visual Studio and it will work.

Alex
  • 840
  • 7
  • 23
  • 2
    Thank you!! I recently installed MalwareBytes Premium and that was the cause for me. I found advice somewhere else to only add the Installer folder to the exclusions but it was obviously omitting the destination of the installation files, so this worked awesomely awesome!! – alejandrormz Jun 13 '20 at 19:49
3

I got it working by downloading the installer separately, rebooting, and running the installer directly.

VS Installer Downloads

Jeffrey Harmon
  • 2,268
  • 23
  • 18
3

I encountered this when trying to update VS2019. I could not rename the Installer folder. Rebooting didn't help. I tried uninstalling everything related to Visual Studio via Control Panel, but the uninstall failed. It removed everything except a subfolder containing VSIXAutoUpdate.exe and some dlls. The installer still would not run.

This final step allowed me to delete the Installer folder and do a fresh install of Visual Studio.

  1. Open Task Manager > Processes Tab
  2. End Process "VSIXAutoUpdate"
  3. Delete folder "C:\Program Files (x86)\Microsoft Visual Studio\Installer"
2

TL;DR

Stop the Task Scheduler service and ensure no open handles for the C:\Program Files (x86)\Microsoft Visual Studio\Installer dir

Details

I just had the same problem, and even rebooting didn't help. So, I dug in!

Process Hacker revealed there was a lock on the following file by the System process:

C:\Program Files (x86)\Microsoft Visual Studio\Installer\resources\app\ServiceHub\Services\Microsoft.VisualStudio.Setup.Service\VSIXConfigurationUpdater.exe.

If I used Process Hacker to close the handle, it just immediately reopened again :/

I thought to check Task Scheduler (since it runs as SYSTEM in svchost), and sure enough there were tasks in there that run VSIXConfigurationUpdater.exe, even though they weren't actually running at that time.

So I stopped the Task Scheduler service, then used Process Hacker to close the handle on VSIXConfigurationUpdater.exe - and this time it didn't return! After ensuring there were no open handles on anything inC:\Program Files (x86)\Microsoft Visual Studio\Installer, the Visual Studio installer was able to update.

Cocowalla
  • 13,822
  • 6
  • 66
  • 112
2

I found the culprit for me was Malwarebytes disabled this and all worked well. Hope this helps somebody.

1

I tried to run through the steps @Janspeed specified, but there were a couple of language folders in the resources directory that were corrupted/locked, so just renaming wouldn't work. I managed to copy most of the file/dir structure (minus the corrupted ones) to a new directory but had to run a chkdsk /f on a restart before I could get those folders freed up and deleted. Once I had this worked out, @Janspeed's steps worked fine, including just deleting the new directory that I had copied everything into.

Bishop
  • 1,011
  • 8
  • 9
1

I ran into this issue today, turns out it was MalwareBytes Endpoint Protection that was blocking the update which is rather annoying.

Luckily I'm the admin and developer so I was able to drop my laptop from the antivirus to enable the update and then re-add it but in a larger corporate environment with red tape this isn't great at all.

1

I had faced the same issue while updating Visual Studio 2017 and 2019. I tried to open the Visual Studio Installer directly as admin and then it worked as expecred.

Vivek Nuna
  • 25,472
  • 25
  • 109
  • 197
1

Update kept failing when using the "Check for Updates" menu item in the VS2019 IDE. When I ran the Visual Studio Installer from the Windows Start bar it immediately prompted to download the latest version of the installer. Once that was done it then offered to update VS2019.

0

I had similar issues while modifying or Upgrading from VS installer. Getting Error: "visual studio installer update failed to download. make sure that you are connected to internet"

Note- I've installed VS-2022 and later installed VS-2019 to open some legacy application code.

Upon checking both the VS installation folders, I found the VS installer is installed in the later installed i.e VS 2019 folder.

So I just renamed the installer folder and run the Visual studio setup for 2022 (not the installer). Now the setup freshly downloaded the installer and I could able to upgrade/ modify the components of the existing installed VS 2022.

hope same needs to follow if anyone facing similar issues.

Rename Installer Folder, Rerun the setup, Modify/Upgrade the Software.

S P
  • 1
  • 1