   about programmatically writing to the windows system folder
  Hi,I'd like to put a simple text file (i.e. non-executable file) into a computer's Windows system folder in order for my application to store some basic information that won't be removed when desinstalling the application (e.g. if the user re-installs the application or a newer version of it, the same settings can be re-used). Is this bad practice?I know most would use the registry for that, but I prefer not because:1. It seems you need administrator priviledges to write to the registry and my user might not be administrator.2. There is quite a bit of data, that would be quite troublesome to put it all into the registry.How would I do this? Is there a simple function that gives me the path to the system folder? Will I also need administrator priviledges there?Thanks!   
  I don't think I would use the system folder unless it was a dll or executable that was supposed to be shared among applications.Anyway, if you are using C++ you can try the GetSystemDirectory function, or if you are using C#, Environment.SystemDirectoryAnother option is to save the application speciffic files in the Program Files directory, and add a registry key to that folder.   ;Quote:Original post by floatingwoods1. It seems you need administrator priviledges to write to the registry and my user might not be administrator.You need to be an administrator to write to the HKEY_LOCAL_MACHINE hive, but any user can write to their own HKEY_CURRENT_USER hive. Also, you need to be an administrator to write to the system folder (assuming you mean Windows\System32 or whatever).You can write to somewhere under CSIDL_COMMON_APPDATA if you want to go that route.   ;Quote:Original post by floatingwoods... that won't be removed when desinstalling the application... Is this bad practice?Yes. When I uninstall something, I want it gone. Or at least have the option to make it gone. If you have a little check box I can click to keep save games and whatnot, that's OK, but you've really got to be able to remove everything in your uninstaller.   ;Quote:Original post by floatingwoodsIs this bad practice?Yes. Unless you are writing a device driver, or some windows kernel component.Quote:How would I do this? Is there a simple function that gives me the path to the system folder? Will I also need administrator priviledges there?Your application is given several locations into which you may put anything:- The installation location (may not be /Program Files)- The appropriate Documents&Settings or Users directory- The temp directoryThe APPDATA location mentioned above seems like best choice if you wish to store something that is intended for every user.Quote:I don't think I would use the system folder unless it was a dll or executable that was supposed to be shared among applications.Even then, with 32/64-bit and XP/Vista/7 differences, as well as SxS mappings, there simply is no real reason to write there manually.And security under Vista and 7 has gotten much tighter, with more users running as non-admin accounts, meaning that trying to modify anything outside of previously provided locations can cause problems.For example, on my installations, I don't use default locations, so I keep program files on D, profiles and my documents on another drive, temp is on ram drive, etc... I really notice misbehaving applications since they seemingly litter all over the disk.Quote:f the user re-installs the application or a newer version of itTo upgrade, the installer offers an option to install into same location as existing version. If they uninstall it, then they want to get rid of it.   ;Quote:Original post by AntheusYour application is given several locations into which you may put anything:- The installation location (may not be /Program Files)Assuming the installation directory is inside Program Files, then you may not put "anything" there unless you give the application administrator privileges. Vista acknowledges that sloppy programmers may stick data in Program Files and so will end up dumping the files into %userprofile%\AppData\Local\VirtualStore\Program Files instead.   ;  If you want to save settings, then save it to the per-user location for application data: CSIDL_APPDATA, System.Environment.SpecialFolder.ApplicationData.   