Archive: All Users Write Access


All Users Write Access
I hope I'm not repeating a post here but I couldn't find what I was looking for here on the forum.

In my installer I'm creating a directory under "All Users" by doing the following:

SetShellVarContext all
CreateDirectory $APPDATA\Foo

This works fine in XP but under Vista I do not have write permissions to the folder or any sub folders or files. When my application creates a file in $APPDATA\Foo it actually ends up being a virtualized file.

Is it true that if I change the permissions of the folder with the AccessControl plugin to allow writing that all sub-folders and files created after will then not be virtualized and actually be writable in the real $APPDATA\Foo and not the virtualized path C:\Users\THEUSERNAME\AppData\Local\VirtualStore\ProgramData\Foo\...?

Thanks for your time


You should never do that. If you allow every user to write to the same folder you allow each user to affect other users. If you want an administrator to be able to change global settings, you should create a separate elevated application or dialog to do that.


We actually just have a database stored there that needs to be accessed by all of our users. That's why it's in the All Users folder. That, as I understand it, is what the All Users folder is for is it not?


So will the AccessControl plugin do what I explained earlier?


The AccessControl plug-in can change the permissions of that folder, but you shouldn't give users a write permission to a common folder. Every change one user makes will affect all other users. That change doesn't have to be with your program. A user can completely delete that database or even corrupt it in a way that your program will crash.


That's OK. This is just a temporary situation where the DB is shared between users. In the meantime, this is the route we've decided.

So, what about virtualization? Will the AccessControl plugin solve that issue as well?


No, that probably happens due to Vista compatibility trick. Adding a manifest should make it go away. If the problem is with the installer, use RequestExecutionLevel. If it's the application itself, you'll have to do it manually. You can copy the installer's manifest and modify it.


Sorry. Both Vista and NSIS are fairly new to me. Are we talking about the Windows Manifest file? As in foo.exe.manifest? Or is there an NSIS manifest file? If it's the former, I'm not quite sure what you mean.

Thanks for the help.


We're talking about the Windows manifest file which can also be embedded in the executable as a resource. That's what NSIS does - it embeds the manifest as a resource when you use RequestExecutionLevel. You can copy that manifest using a resource editor.


Ah I see. So what your saying is I could modify the manifest to give our application Admin level privileges? If that's the case, wouldn't the UAC prompt come up asking permission to run the application?


No, that's not what I'm saying.

The manifest has one more "feature" up its sleeve. It tells Vista the application knows what Vista is and so handles all sorts of cases like this one. Vista therefore turns off all sorts of compatibility tricks it has for older applications.


I understand now. Sorry for the confusion. Do you have a snippet I can add to my manifest to produce these effects? Or perhaps a link I could check out?


The manifest that the installer uses has all you need. The following goes under <assembly>

<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel level="asInvoker" uiAccess="false"/>
</requestedPrivileges>
</security>
</trustInfo>

Thank you very much. I'll give this a try and see if it solves our problem.

Your help is very much appreciated and thank you for your quick replies.