Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 640871
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T21:00:03+00:00 2026-05-13T21:00:03+00:00

I am developing a CLI application in Ruby, and I’d like to allow configuration

  • 0

I am developing a CLI application in Ruby, and I’d like to allow configuration in Unix via the standard config file cascade of /etc/appnamerc, ~/.appnamerc. However, the application is also meant to be run in a Windows environment, and I’m unsure of where one would put a file like /etc/appnamerc (C:\windows\system32\etc\drivers does not seem like it would be the correct place). Further, whatever scheme I decide for looking up a system configuration file also needs to consider the different versions of Windows, i.e. C:\Users vs. C:\Documents and Settings. As far as user-specific configuration goes, I am also unsure of where to have my application look for a user-specific configuration file, and what the standard naming convention for something like that would be.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T21:00:04+00:00Added an answer on May 13, 2026 at 9:00 pm

    What you’re looking for is the SHGetKnownFolderPath function (or—on older versions of Windows—the SHGetFolderPath function).

    While Windows has conventions what those paths are and where they reside this is entirely dependent on version, configuration and other factors so hard-coding folder names is a bad idea. Above function has been the way to get those “special” folder locations since the beginning, though.

    The main argument to those functions is either a KNOWNFOLDERID or a CSIDL which specify which folder you want to get.

    You have two different “flags”, actually: User-specific and machine-specific on Windows. A location can be specific to a single user or available to all users and it can be specific to a single machine or be available on all machines the user has access to. Those will be distinguished below.

    The ones you do want here are the following:

    • FOLDERID_ProgramData/CSIDL_COMMON_APPDATA: This is for program settings for all users, so approximately the equivalent of /etc/foorc. You should create a directory for your program there and store your all-users config there. Note that this directory is not writable for normal users (just like /etc is too, I think). This directory is machine-specific, though.
    • FOLDERID_RoamingAppData/CSIDL_APPDATA: This is for user-specific settings or application data. For most use cases this should be the primary place where you put this because it will be saved in the roaming profile—therefore it’s accessible on every machine the user logs on. So this is the equivalent of your ~/.foorc. The same rules as for the all users variant apply.
    • FOLDERID_LocalAppData/CSIDL_LOCAL_APPDATA: This is the machine-specific location for user-specific data. Usually this should be used for things like caches which are nice to have around but are not necessary to copy over the network every time the user logs on. Note that Thunderbird gets this very wrong in storing the local copy of IMAP mails in the roaming profile—this is kinda fun when you have several GiB of data in there.

    Generally, please avoid just sticking your .foorc in the user’s profile folder. Windows is not UNIX and files preceded by a dot are not automatically hidden (there is a file system flag for that). To me it’s just an annoyance if applications do that because the user’s profile directory is not the place for that kind of thing on Windows. Likewise, the Documents folder is not a good place for applications to create stuff without the user’s consent or explicit action.

    From Ruby you should be able to call those functions using the Win32API library. This looks vaguely promising (though ugly); however, I don’t know enough to actually show you a working example.

    A last-resort option would be to use environment variables. The environment variables ALLUSERSPROFILE, APPDATA and LOCALAPPDATA are the respective equivalents of above FolderIDs.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 385k
  • Answers 385k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Having the URL not change is very bad practice. Not… May 14, 2026 at 11:20 pm
  • Editorial Team
    Editorial Team added an answer You can do it like this: SELECT grid FROM MyTable… May 14, 2026 at 11:20 pm
  • Editorial Team
    Editorial Team added an answer Any PHP files containing sensitive data, such as database password,… May 14, 2026 at 11:20 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.