0

I make an application and make setup file using VS setup project. This work fine and create default text files into Program Files Folder for winodw 7/vista .but can not modify these files or create any new files.

There are few text files need to create ,modify during application running ,but in windows 7/vista unable to create,modify files.I am using full default admin right for these OS. If iuse C: root path then application work fine or for win XP no problem.

I think UAC restricting to perform these opeartion. But i do not know how to change these restriction using vb.net, whenever application start.

I found one solution that , if change user rights manually then this problem solved. Follow these step to change your account settings. Control Panel-->User Accounts and Family Safety-->User Accounts-->Change User Account Control settings-->Never notify(Set tab to never notify). After this change need to restart system. Now can make all changes like windows XP into Windows 7.can also make changes into program files.

Its working fine, but need to make these changes manually in OS.

but its not efficent solution.

So if any one knows how can make these changes by coding that will nice.

asked Jul 27, 2011 at 8:12
4
  • possible duplicate of Does Windows 7 have the same problem as Vista? Commented Jul 27, 2011 at 8:52
  • 2
    Do not make these changes in code! You need to comply with UAC, not work against it. No Windows application should assume it has write privileges to the Program Files directory. EVER. Commented Jul 27, 2011 at 8:52
  • yes vista also have the same problem Commented Jul 28, 2011 at 1:21
  • Yes, but it's not a "problem". It's a solution. Use the Application Data directory designed for this purpose. Apps can't write to system or program directories. Period. Not sure where the question here is other than "I don't like that". Tough. Users didn't like you monkeying around with system files, either. Commented Jul 28, 2011 at 1:28

1 Answer 1

2

I seriously doubt whether you can create and delete files under Program Files Folder through code in windows7/vista. Even if there is a way, I would consider doing this a bad design and a security flaw.

If you want to create/modify/delete files during you app execution. you can create them "C:\Users\\AppData\Local\\ and do whatever you want to do over there.

Program Files Folder is not the place for storing temporary data.

answered Jul 27, 2011 at 8:20
Sign up to request clarification or add additional context in comments.

5 Comments

gupta thanks for your answer.Yeh its not good place to copy,modify files. prg file is the folder hold installed applications also.So my app folder reside in prg files and there are few files need to keep there and make changes into those files.
@muhammadhanif: Irrelevant what kind of data it is. You do not have write privileges to the application directory. That's completely by design. Use the AppData folder, as suggested. More info here.
@muhammad hanif, one of Microsoft's biggest hurdles over the decades is the problem of developers writing files all over the system. In the older days people would write directly to the root of the hard drive or the windows/system folders causing bloat and conflicting files, especially when everyone just names their file "config.ini". So Microsoft finally took a stance and said "Programs" go into "Program Files" and program data goes into "AppData". You may think you have an exception to the rule, but then again so did everyone 20 years ago.
Right. The "exceptions" are why the rule was created. Like most rules operating systems now impose on developers. Back in the "olden days", the OS could actually trust application software to be responsible and do the right thing. Those days are long gone, as evidenced by the flood of such questions on SO and the refusal of people to accept the good advice that has been provided to them.
I agree with Chris and Cody that as application developers, we need to be responsible in terms of what parts of OS are being touched by our code.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.