The Design of Software (CLOSED)

A public forum for discussing the design of software, from the user interface to the code architecture. Now closed.

The "Design of Software" discussion group has been merged with the main Joel on Software discussion group.

The archives will remain online indefinitely.

Help with Vista's security model and my app

I have an application that needs to start when the user logs in. In XP I added the app to the registry under


In Vista, the program starts ok but it seems to be running in a very restricted environment because it returns NULL on fopen(write). How do I get my program to run on startup with the users permissions and not super restricted? I have asInvoker in the manifest and the program works fine if I double click on it manually when I log in. Any thoughts? Thanks.


p.s. I could get rid of the fopen but I need it to write out a log file so I know what is happening.
Wednesday, October 29, 2008
Have you read through "Developing Applications that Run at Logon on Windows Vista?"
Wednesday, October 29, 2008
My guess would be that you're trying to write to a folder that standard users don't have permissions to write to (like say the program files folder). You can either add appropriate permissions during install, or write to a different folder.

I presume it works when you double click it because you've turned off UAC.
Wednesday, October 29, 2008
+1 Adam.

Writing to Program Files folders in vista is a no-no.  For that matter, writing to Program Files folders in XP is a no-no, we were just usually able to get away with it anyway.
Joel Coehoorn Send private email
Wednesday, October 29, 2008
My guess is that your program doesn't work correctly under XP either if run as a limited user. Get that fixed first and Vista will probably be no problem. As others have stated, you are probably trying to write to a folder that the user doesn't have access to because of permissions.
dood mcdoogle
Wednesday, October 29, 2008
The recommended location to write application specific data is to write it to the hidden folder C:\ProgramData, which you can query the location as an environment variable, i forget the exact semantics, but it is standard recommended practice, if you want to store data per user there is another location for that.

In one of my applications, we had to edit the machine.config for 32bit and 64bit machines, this was insane because of the virtualization process where you check any environmental variable for current executing architect it would return 32bit if it is 32bit process or 64bit if it was 64 bit process, the only way for us to tell for sure was manually checking to see if %WinRoot%\Microsoft.Net\Framework64 folder existed.

Wednesday, October 29, 2008
As mentioned by the above poster:

By default, under Vista, that returns:

By default, under Win2k or XP, that returns:
C:\Documents and Settings\All Users\Application Data

Under Vista, you'll get a UAC if the program isn't running from C:\Program Files and one tries to access ProgramData.
Peter Send private email
Wednesday, October 29, 2008
That was it! I was writing to the program files directory. Thanks for all the help.
Thursday, October 30, 2008
Sheesh... when will this finally be common knowledge instead of us having to keep helping these people?
Friday, October 31, 2008
This will never be common knowledge.

Most of the reason why UAC exists is that people *should* have been using Xp correctly, but couldn't because of the billions of crappy applications that insist on writing user-specific data in the program's directory.

No matter how many UNIX (and Linux/BSD/etc) nerds demand Microsoft get Windows security right, the second they do it right people can't (or won't) accept the consequences of security.

As for people who whinge about UAC and say that just demanding everyone type 'sudo' a lot is much better, I'm not convinced they're entirely sane.

Sunday, November 02, 2008
One way I can think of is to write to %USERPROFILE% --- the path is different from XP to Vista, but does not matter, right? Just call GetEnvironmentVariable() or something similar.

%ProgramFiles% is DEFINITELY not the right place to save your config etc., even on XP.
Thursday, November 13, 2008
On Vista, use SHGetKnownFolderPath
On other versions, use SHGetFolderPath

Never use environment variables, even if that "seems" to work.

Monday, November 17, 2008

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics
Powered by FogBugz