Click here to Skip to main content
13,049,684 members (65,840 online)
Rate this:
Please Sign up or sign in to vote.
See more:
Hi All,

i developed an application in win32 with VS2005 on WIN-XP platform. this application is working as expected in WIN-XP but not working in VISTA. vista is not allowing my application to create some files in program file(x86). if i disable the UAC then its working fine. i got some information from internet and i added a manifest file also, but still its not working.

please suggest me how can i fix this issue in my application.
i don't want end user to disable UAC for using my application.

any help is very much appreciated.

Thank You.
Posted 5-Apr-11 0:19am
Updated 5-Apr-11 0:21am
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

You should use the Application Data directory instead. You can do whatever you want there.
SafarTimura 5-Apr-11 7:11am
I have a similar problem on Vista, Olivier correctly states that you need to use the application Data. It might well be a hidden directory called app data under the user which is signed in however.
Olivier Levrey 5-Apr-11 7:48am
Thanks for the vote.
Jayant Narayan Dash 5-Apr-11 10:06am
Thanks Olivier,

but vista also not allowing to add a registry entry if UAC is enabled.

is it possible to fix this issue by digitally sign my app.
Kim Togo 5-Apr-11 10:15am
Just remember to use a function that returns where application data folder is. Do not hard code the location of Application Data folder.
Olivier Levrey 5-Apr-11 10:16am
I have no knowledge about digitally signatures, sorry.

Concerning registry access, the best option is not to touch it at all. I mean, you can of course add entries while installing your application, but while it is running you should access it only in read-only mode. It is better to store all settings in a file rather thant registry.
Olivier Levrey 5-Apr-11 10:17am
Yes you are absolutely right. SHGetSpecialFolderLocation should be OK.
Jayant Narayan Dash 5-Apr-11 10:37am
Thanks Olivier,
for your so... quick response.
i know some applications were writing data in program folder. so i thought there must be a way to achieve this.

any way your soln is helpful.
Olivier Levrey 5-Apr-11 10:41am
Maybe there is a way, but I don't know it.
I am glad I could help.
SAKryukov 5-Apr-11 12:31pm
Correct advice. My 5.
SAKryukov 5-Apr-11 12:33pm
Well, installation applications... whatever you do, privileges should be elevated. Everything else is just wrong. No need to mimic bad practice.
Kim Togo 6-Apr-11 2:25am
In the installation program, you can always change NTFS security settings under "Program Files" for that folder you wish to write files to.
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

In general, there is read-only in "Program Files" folder for no admin programs. Try read this link New UAC Technologies for Windows Vista[^]

Best way is to use ProgramData for data which often change. You can have a manifest file that tells Windows Vista it requires administrator rights.
Jayant Narayan Dash 5-Apr-11 10:02am
hello Kim,
thanks for your solution.
just i curious to know how other applications installing and creating files at "program files" folder and adding some registry entries(is vista will allow an app to add a registry entry if UAC is enabled).
can it be fixed by adding a digital signature to my application???

please update me if u have some other solution.
Kim Togo 5-Apr-11 10:12am
Installations program (MSI or EXE) has a manifest witch tells Windows Vista/7 that to run this program "Admin rights is required". Then Windows Vista/7 will prompt the use to allow this program to run in elevated permission. When in elevated rights, the program has access to read and write to "program folder" and registry. In the link, it says that 32 bit applications can run in Virtualization, that improve application compatibility. The program think it is writing to "Program folder", put behind the scene it write folder is in another folder.
Jayant Narayan Dash 5-Apr-11 10:37am
thanks Kim,

i ll write my data to app data folder may be this is the only solution.
if you get any soln to my approach then please let me know.
Kim Togo 6-Apr-11 2:27am
In your installation program, you can always change NTFS security settings under "Program Files" for that folder you wish to write files to. And give local user group "Users" or "Authenticated Users" read and write access.
Jayant Narayan Dash 9-Apr-11 0:16am
hi kim
so what i can do if i want to add a registry entry in my application.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web01 | 2.8.170713.1 | Last Updated 5 Apr 2011
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100