Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Save a setting for All users under Vista

I need to save a setting which is then available to all users of the application on the given machine. It needs to work on Vista/Win 7, and the application won’t be started as administrator.

  • Can’t Save to program directory as the Program Files folder is protected on Vista
  • Can’t save to HKEY_LOCAL_MACHINE as that’s protected too
  • Can’t save to server or web-service

Where can I save data to? Even if the application rights were somehow elevated during execution, my worry is that the registry is now virtualised in Vista – and so I will end up with a special HKEY_LOCAL_MACHINE which is actually only for the current user.

I'm using .NET

like image 304
monibius Avatar asked Oct 10 '09 14:10

monibius


1 Answers

Common Application Data

System.Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData)

This is a filesystem path that you can use to save data across multiple users and multiple versions of the operating system. The path might be different depending on the version but because you are using environment variables the above line will resolve to a usable path.

Edit:
Wanted to add this as a note since it was only implied; it does not require elevated permissions to write to this directory, it is meant for exactly this purpose.

like image 193
Quintin Robinson Avatar answered Sep 18 '22 16:09

Quintin Robinson