From: djberg96@... (Daniel Berger) Date: 2004-02-26T12:05:31+09:00 Subject: Re: Profile-independent directory specification for NT? "Florian G. Pflug" wrote in message news:<20040225194848.GA24254@foobar.solution-x.com>... > 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 ;-) ). In theory, each user has a home directory set. You can see if it's set by going to Start -> Settings -> Control Panel -> Users and Passwords -> Advanced -> Advanced (again) -> Click on users -> right click to view properties -> click "Profile" tab. You can use the win32-etc module to get at this information as well in a language-neutral way: require "win32/etc" include Win32 Etc.passwd{ |s| p s.name p s.home_dir } Often times, however, this value isn't set and you have to resort to environment variables. > 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 You can use "win32/registry" which ships with 1.8.1. However, there's no advantage to using the registry over the environment variable since the two are identical as far as I know. Regards, Dan