Archive: question about installation folder on win7


question about installation folder on win7
I having some confuse with installation folder on win7 client pc in network environment

if I want to install my program on C:\Program Files\myprog then I will need administrator password .
after I install when I try to run my program I get error cause my program can't create files in the installed folder . I need administrator to run my program without problem.

what should I do cause I don't want user to run my program as admin .

I found that if I change the installation path to c:\myprog , I can install it as user and run it as user without any problem .

is this the correct way ? I don't think install c: root is correct way

any advice?:confused:


Per user applications shouldn't be installed in Program Files, they should go in $APPDATA or somewhere like that.

Stu


Originally posted by Afrow UK
Per user applications shouldn't be installed in Program Files, they should go in $APPDATA or somewhere like that.

Stu
Nope , this is not per user application .

I don't have any problem on winxp client pc . not sure what is the best solution that can work on xp and win7.

I don't want endup with 2 different installation

There are two things you can do. First, you can test the selected installation directory for writing privileges, and if the user doesn't have them do not allow installation there. I've pasted some code that checks this here: http://forums.winamp.com/showthread.php?t=317018
Second, you can create your app's (config?) files during installation and use the accesscontrol plugin to give all users write access to those files.

(Note that it is a very bad idea to give all users write access to the whole installation directory! The admin would believe that, since the dir is in Program Files, it's a safe directory. He then might end up admin-running an .exe that was infected or otherwise compromised by a regular user.)


Edit: actually, both these methods are wrong. What you SHOULD do is to change your application to save files to MyDocs or AppData, instead of $instdir.


settings really shouldn't be written in the program folder under any case - that is what XP started (though poorly enforced) and Vista/Win7 have properly enforced this requirement with the need for admin access to write into the program files directory.

like stu says, using the appdata folder is the norm / suggested way for dealing with settings.

from a bit more looking (as i couldn't remember it after last looking into this early last year), CSIDL_COMMON_APPDATA (used with the SHGetSpecialFolderPath OS api function - can't remember if NSIS does this natively or only via the system plug-in) is the equivalent place for saving a programs settings but in a folder with the correct access (works on Win2k and higher and seems to be valid under Win9x as well).

for XP this typically maps to C:\Documents and Settings\All Users\Application Data and with Vista / Win7 it goes to C:\ProgramData

-daz


That would be either $LOCALAPPDATA or $APPDATA, using shellvarcontext all. Can't remember which one.

Edit: Although it's not guaranteed that that folder is world-writable. If an admin creates a directory there, he gets ownership and users are left hanging.


for NSIS and reading the docs i'd expect it to be $APPDATA with SetShellVarContext all.

though really the app needs to be changed to be more compliant than having the installer fiddling things as if the app isn't working correctly and not following things then it really doesn't matter what the installer does as it won't really have any effect.

-daz