From: eg Date: 2004-02-27T19:19:46+09:00 Subject: Re: Profile-independent directory specification for NT? Florian G. Pflug wrote: > On Wed, Feb 25, 2004 at 10:03:51PM +0900, Moran, Craig M (BAH) wrote: > >>Is there a way to specify a directory in Ruby that is profile-independent >>for the Windows NT variants? For example, if I wanted to do this in VBA for >>the currently logged in user's My Documents folder, it would look like this: >>ProfilePath = Environ("USERPROFILE") & "\My Documents\" >>This way, regardless of who is logged in and runs the script, it will always >>point to their own My Documents folder. Thanks in advance for the help- > > Be aware that this is only correct on english versions of windows. In german > e.g, the folder is not named "My Documents" but "Meine Dateien" (or > something like that - don't use windows very often ;-) ). > > I believe that the windows registry is the right place to get that > information from. (I have to admit though, that I have no idea how you could access > the registry from ruby, and where you find this information there). > > greetings, Florian Pflug > > In Win2K and up you can call a Shell function SHGetFolderPath( ) which can be used to return this directory. for example, SHGetFolderPath(NULL, CSIDL_MYDOCUMENTS, NULL, 0, szPath) Alternatively, you can look in the registry in the following branch: "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" Under Win2K and up, there will be an entry labelled "Personal" which contains this directory name.