32

I noticed recently IISExpress & My Web Sites folders are getting added to the My Documents folder on my Windows 7 machine. I recently installed VS2012, so I'm guessing that's the culprit, but I haven't been able to find anything on line that explains how to change these defaults, if possible.

Jasperan
  • 2,154
  • 1
  • 16
  • 40
TimeTrap
  • 1,142
  • 1
  • 14
  • 18

3 Answers3

30

Microsoft cluttering up my 'Documents' folder with all their programs' (junk) folders drives me insane as well. I have conceded somewhat by creating a Data folder under my Documents folder, where I am pointing all MS apps (and others apps such as Firefox's profile folder) to for all their (generally unwanted) folders, and with a subfolder created for each program/suite. At least this way I can easily back up all settings when I back up my 'Documents' folders.

Anyway, VS2012 installs IIS Express, which is what is causing these folders to be created. I have found two solutions for dealing with the unwanted folders.

  1. Uninstall IIS Express. You can do this from the normal Windows 'Uninstall a Program' part of Control Panel.

  2. Change the folder location that IIS Express uses, as follows. Be warned: anyone doing this risks causing problems with their computer if you don't know what you are doing, so you do so at your own risk. Please make appropriate backups along the way as well too!

    a) Close Visual Studio.

    b) Create a new folder for the IIS Express sub-folders:

    eg. D:\My Documents\Data\Microsoft\IISExpress

    c) Move the existing unwanted IISExpress subfolders (config, Logs, TraceLogFiles) from your My Documents > IISExpress folder to the folder created in step b).

    d) Create a new folder for the My Web Sites folder, I suggest also under the folder created in step b).

    eg. D:\My Documents\Data\Microsoft\IISExpress\Websites

    Under this folder, create a website for the default IIS Express website (in case it "auto-magically" reappears it's ugly head again later on).

    eg. D:\My Documents\Data\Microsoft\IISExpress\Websites\Default

    e) Go to the newly located config folder at:

    eg. D:\My Documents\Data\Microsoft\IISExpress\config, and:

    i. Open the file applicationhost.config in your text editor (eg. Notepad).

    ii. Find the node sites > site > application path > virtualDirectory path for WebSite1, and change the physicalPath value from %IIS_SITES_HOME%\WebSite1 to the IIS Express default website folder you created in step d).

    Eg. %IIS_SITES_HOME%\Websites\Default.

    Note that %IIS_SITES_HOME% points to your 'Documents' folder (this appears to be a "feature" of IIS Express, I can't find a way to change it, and it appears to be auto-configured when IIS Express starts up, which it does by using the applicationhost.config file).

    Do the same for any other sites created by IIS Express.

    f) Create a new registry entry pointing IIS Express to the new folders you created (partly explained by MS here: http://www.iis.net/learn/extensions/introduction-to-iis-express/iis-80-express-readme). FYI the registry key doesn't previously exist, as IIS Express uses a default of my Documents unless this key exists:

    i. Open the Windows 'Run' box, eg. (Windows Key) + R

    ii. Type regedit

    iii. Navigate to key: HKEY_CURRENT_USER\Software\Microsoft

    iv. *Right click* the Microsoft key (that you have just navigated to), and choose: New > Key

    v. Type IISExpress

    vi. *Right click* the IISExpress key that you have just created, and choose: New > String Value

    vii. Type CustomUserHome, and hit the Enter key to save it.

    viii. Double-click the CustomUserHome string to enter a value for it, and for the Value Data: field, type in the path to the new IIS Express folder you created in step b), for example: D:\My Documents\Data\Microsoft\IISExpress. Press OK, and you can now close the Registry Editor.

    g) Reopen Visual Studio, and it should start using the new folders, as well as not create the folders in your Documents folder anymore. Yay!!!!!

FYI, when I did this all, I actually did it in a slightly different order (creating the registry key first), but this order was the easiest way to explain it all. Whether you create the key first or last shouldn't matter, as long as you do all the steps. Good luck!

Matty J
  • 3,116
  • 32
  • 31
  • 2
    I've tried this, but then my visual studio started throwing errors. "failed with the error: Filename: redirection.config". – Peter Wright Dec 02 '14 at 09:24
  • 1
    Hi @PeterWright, yes it seems to cause a problem with VS2013 (the tip was originally for VS2012 actually), I had the same problem. I ended up resolving it by putting a shortcut named `IISExpress` in my 'My Documents' folder, and pointing it to where I had relocated the files. Or the other solution is to let it actually be there, and not move it. From what I've seen, MS have acknowledged it as a bug, but have not fixed it yet. – Matty J Dec 02 '14 at 11:38
  • I wish I could, unfortunately our group policy maps our "My Documents" folder to a UNC share which means I cant convert the folder to a symbolic link else where. I've been having trouble using the `IPrinciple.IsInRole()` method. There is a bug where the method returns false instead of true when the ASP.NET application uses a UNC Share. The website itself does not, but is hosted in IISExpress via visual studio which does pull its config files off the UNC share. See this [KB articale](http://support.microsoft.com/en-us/kb/894432) – Peter Wright Mar 26 '15 at 15:36
  • Hey @MattyJ, thanks for all the info. I'm working with VS2015 Community and Windows 10 and I tried all of the above (incl. the shortcut from your comment). And I always get `error: Filename: redirection.config` and the project cannot be loaded. Any experience with VS2015? The only thing which really works is leaving the folder there and that doesn't really satisfy me.. – PzYon Sep 29 '15 at 05:29
  • Hi @PzYon, I haven't tried it on Win10 / VS2015, but if you're getting the same error as per VS2013 I can only assume that it won't work to remove all folders inc. IISExpress still / there is a bug still that hasn't been resolved. A real shame, because I really hate them putting all their junk in my Documents folder and cluttering it up / forcing me to do things their way rather than my own. – Matty J Sep 30 '15 at 11:59
  • Hi @MattyJ, thanks for your reply. Then I will leave it where it is. Not a fan of the "cluttering-up" either.. Thanks any way. – PzYon Sep 30 '15 at 12:23
  • This worked great for VS2019. Any ideas how to stop VS19 from also recreating the, "Visual Studio 2019" folder? I've relocated the project and template locations, but vs19 still creates an empty folder in my documents folder. So annoying! – eaglei22 Jul 15 '21 at 17:40
  • NVM, this solution worked well for VS2019 : https://stackoverflow.com/questions/42703179/how-to-change-visual-studio-2017-folder-location Just don't forget to unload the hive (otherwise it won't unload until a restart of windows) or VS will throw an error on start. – eaglei22 Jul 15 '21 at 18:43
9

A Tricky solution

  1. Make a copy of your C:\Users\<user>\Documents\IISExpress folder first
  2. Create a symbolic folder called IISExpress inside the C:\Users\<user>\Documents folder using the following command
    • mklink /J C:\Users\<user>\Documents\IISExpress D:\IISExpress
  3. Move all the content from your copied IISExpress into D:\IISExpress
  4. Thats all
spottedmahn
  • 14,823
  • 13
  • 108
  • 178
Sukesh Chand
  • 2,339
  • 2
  • 21
  • 29
  • 1
    I just tried this on my local work machine, and it was very easy to do and it worked! :) This is a much easier solution as I don't have to play with registry settings and all that mess, which for me, is locked down on my work machine. – Andy Aug 24 '18 at 19:35
1

If you're just looking to declutter your Documents folder, one simple workaround is to set the unwanted folders to hidden so it's no longer visible.

You can do this by right clicking on the IISExpress folder > Properties and checking the hidden property at the bottom. The folder will still remain in your Documents folder but won't be visible to you. If for some reason you want to access these folders again, you can toggle hidden item visibility in File Explorer's View tab.

Jasperan
  • 2,154
  • 1
  • 16
  • 40