Professional Web Applications Themes

Profile-independent directory specification for NT? - Ruby

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 Doents folder, it would look like this: ProfilePath = Environ("USERPROFILE") & "\My Doents\" This way, regardless of who is logged in and runs the script, it will always point to their own My Doents folder. Thanks in advance for the help- Craig...

  1. #1

    Default Profile-independent directory specification for NT?

    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 Doents folder, it would look like this:
    ProfilePath = Environ("USERPROFILE") & "\My Doents\"
    This way, regardless of who is logged in and runs the script, it will always
    point to their own My Doents folder. Thanks in advance for the help-
    Craig


    Moran, Guest

  2. #2

    Default Re: Profile-independent directory specification for NT?

    The environment is available under the hash ENV. So, you can do
    something like:
    ProfilePath = ENV["USERPROFILE"] + "\\My Doents\\"
    basically like you said you'd do with VBA.
    Jim Guest

  3. #3

    Default Re: Profile-independent directory specification for NT?

    On Wed, Feb 25, 2004 at 10:03:51PM +0900, Moran, Craig M (BAH) wrote: 
    Be aware that this is only correct on english versions of windows. In german
    e.g, the folder is not named "My Doents" 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


    Florian Guest

  4. #4

    Default Re: Profile-independent directory specification for NT?

    "Florian G. Pflug" <org> wrote in message news:<solution-x.com>... 
    > Be aware that this is only correct on english versions of windows. In german
    > e.g, the folder is not named "My Doents" but "Meine Dateien" (or
    > something like that - don't use windows very often ;-) ).[/ref]

    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.
     

    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
    Daniel Guest

Similar Threads

  1. Invalid Authorization Specification
    By Kevin in forum Coldfusion Database Access
    Replies: 3
    Last Post: July 28th, 10:17 PM
  2. Invalid Authorization Specification
    By Mrtechguy in forum Coldfusion Server Administration
    Replies: 1
    Last Post: July 10th, 04:52 PM
  3. FH file specification
    By Tomy in forum Macromedia Freehand
    Replies: 2
    Last Post: January 18th, 04:25 AM
  4. Replies: 9
    Last Post: July 22nd, 11:24 PM
  5. PDF Language Specification
    By Mike_Masri@adobeforums.com in forum Adobe Acrobat Windows
    Replies: 3
    Last Post: June 6th, 12:04 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139