Cannot write values to my .ini files in Vista


When my 2008 desktop app gets installed, I also copy MyApp.ini file in windows folder. Then the user runs my exe and first time it asks for SQL Server name. The user enters this name and I write to Myapp.ini. But I find that I can write this values from my for XP but on Vista, this file cannot get modified. Even I open this file outside my app using Notepad, even then I cannot save the changes. Please Help.

Who is Participating?
F IgorDeveloperCommented:
You need to run the app "as administrator" since Windows folder is write protected for users in Vista. If you want to use .ini files you should consider to write config values in another location like the app directory (if it's not protected by the system like "Windows" and "Program files" in vista ...

also you can  use the new facilities for writing config files using the class

A complete tutorial :
vj_miAuthor Commented:
But I am already logged in as administrator....

You may be logged in as Administrator but with Windows Vista and new operating systems came with UAC( User Account Control) a security feature. In your case even though you logged in under Administrator account the applications that you launch run under standard users. You want to create a folder in Public Documents or Application Data and add your files into that location since they have both read and write permissions for standard users.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.