I am working on a python addin for ArcGIS 10.2.2 and I would like to set the default path for the "file open" command to a user-specified location after a script tool executes. One of the functions that my addin performs is to launch a script tool that copies some .mxd's to a user-specified location. I would like to use that location as the default path, so users can access the other mxd's that were copied by the tool without having to navigate to that folder. I have used the comtypes module to get a reference to the current document, and it seems I can wrap any of the ArcObjects interfaces I will need. Is there a way to access the property that the Open command uses to open the explorer window? Any suggestions about where to start digging into ArcObjects would be appreciated.
I believe that the file open dialog uses the registry value stores here;
HKEY_CURRENT_USER\Software\ESRI\ArcCatalog\Settings\LastBrowseLocation
Take a look at http://code.activestate.com/recipes/66011-reading-from-and-writing-to-the-windows-registry/ on how to read/set the registry value with python.
Owain
Thank you for your reply Owain. I looked in the registry, and on my machine (Windows Server 2008 R2 with ArcGIS 10.2.2), the LastBrowseLocation entry is here:
HKEY_CURRENT_USER\Software\ESRI\Desktop10.2\ArcCatalog\Settings\LastBrowseLocation
Unfortunately, the string doesn't match the path that opens in the open dialog. I tried manually changing the value, and the open file dialog didn't open to the path that I specified.
The entry that controls the path is here:
HKEY_CURRENT_USER\Software\ESRI\Desktop10.2\ArcMap\File Path
Thanks to Owain for providing the example on how to change the value for this key using python.
Glad you found it alright, my mistake giving you the Arc Catalog registry key location.
Owain