How to Update a Host’s Folder in %My Documents%

VSTA hosts use a host specific folder under %My Documents% (or %Documents for Vista) for various purposes.  This is where the settings file is stored and is the default save location is for new VSTA projects for the host (unless a different location is specified under the registry entry NewProjectLocation).

Most configuration settings can be updated by deleting the host context hive under the local machine hive (see Note 1 registry location), then running vsta setup for the host.  Unlike other registry settings, to update which folder is used in %My Documents% the host context hive under the local user hive (see Note 2 for registry location) must be deleted prior to running vsta setup for the host, and will be populated the next time VSTA is run for the host.  This context hive must be deleted if specifying the folder under %My Documents% with either the AppName or UserFilesFolderName registry entries.

The folder under %My Documents% which will be used is determined by the UserFilesFolderName, which specifies which folder under %My Documents% will be used (see Note 3 for examples).  If no UserFilesFolderName is specified the AppName is used, which specifies the title to appear in the VSTA IDE title bar.  If no AppName is specified, the hostId is used. 

This host specific folder under %My Documents% will also be the default save location for new projects unless a different location is specified with the NewProjectLocation entry, which specifies the absolute location of the folder which will be used  (not under %My Documents%, see Note 4 for examples).

Note 1-  The context registry hive under the local machine registry hive is located at: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VSTAHost\<HostId>\9.0

Note 2- The context registry hive under the local user registry hive is located at:  HKEY_CURRENT_USER\Software\Microsoft\VSTAHost\<HostId>\9.0

Note 3- The UserFilesFolderName entry specifies which folder under %My Documents% the host will use, not an absolute path.
                Example good:  “ShapeAppDocuments”
                Example bad:  “C:\ShapeAppDocuments”
 
Note 4- the NewProjectLocation entry specifies an absolute folder which will be the default save location for new VSTA projects for the host.
                Example good:  “C:\ShapeAppDocuments”
                Example bad:  “ShapeAppDocuments”

For more information on host registry settings, please refer to MSDN which now features VSTA v 2.0.  Click here to go to the Registering a Host Application section.

This applies to VSTA 2005 (v1) and 2008 (v2), the registry hives used above are for VSTA v 2.

Posted Aug 25 2008, 12:33 PM by Melody
Copyright Summit Software Company, 2008. All rights reserved.