in reply to Windows convention for per-user configuration files for a Perl application

As jcwren says $SYSTEMROOT on NT works fine, for 2000 you will want to make sure that you substitue $SYSTEMROOT with "Documents and Settings". They have changed the location of profiles with 2k. Probably the best way to do this on 2k (and quite possibly NT - I don't have a box here to try) is to forego the $ENV{USERNAME} and snag $ENV{USERPROFILE} instead. This will point to the correct path for the profile. Again, not sure about win 95/98 machines.

HTH
  • Comment on Re: Windows convention for per-user configuration files for a Perl application

Replies are listed 'Best First'.
(jcwren) RE: (2) Windows convention for per-user config files for a Perl app
by jcwren (Prior) on Oct 16, 2000 at 23:21 UTC
    That variable is supported on NT 4.0, and is a better way to do it. I'm really annoyed at myself for missing that, too!.

    An even more important reason that this way is better is that although the user name is known, it's possible for one or more profiles to exist for a user. In my case, I have 'jcw' and 'jcw.000' as profiles on the machine, and 'jcw.000' is the active profile. If I were to use the username of 'jcw' to select where to write the profile, I would be writing it into the wrong directory.

    Excellent call, the_slycer!

    --Chris

    e-mail jcwren

      But you don't select the username "jcw". You just write to and read from HKEY_CURRENT_USER!

      Now, if you wanted to set per-user items in the Win32 registry for other users, then I'd say "Give up".

      Note that I'm not advocating (nor discouraging) the use of the Registry for stuff like this. I find it a "mixed blessing" and have arguments on both sides.

              - tye (but my friends call me "Tye")
      Every time that my NT box dies and the IT guys rebuild it my user profile directory changes...

      From a DOS window:

      C:\>echo My name is: %USERNAME% My home is %USERPROFILE% My name is: ddickinson My home is C:\WINNT\Profiles\ddickinson.002

      All the best,
      DouglasDD