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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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 :

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.