본문 바로가기

개발 관련

[inno setup] non-admin으로 설치파일 만들기

[inno setup] non-admin으로 설치파일 만들기

Posted August 4th, 2008 by kyle

Most Windows applications require admin rights for installation, which explains why most users run as admin. It also explains why software viruses and spyware are so rampant and why Microsoft invented User Account Control in Windows Vista. Note that even applications that require admin rights for installation should run properly for non-admin (and non-elevated Vista) users.

Sometimes, it does make sense to allow an application to be installed without requiring administrative privileges (which we do for Ultra Recall). Some would argue this is just a way to subvert the IT police, but it doesn’t sidestep any security restrictions or permissions that the non-admin user already has, and sometimes the IT police are more like Nazis anyway.

Inno Setup is a popular tool for creating program installers, and it is fairly simple to create a non-privileged installer with this tool.


The first thing to do is add


PrivilegesRequired=none


to the [Setup] section of the installation script. This will cause Windows to run the install program without elevation for non-admin users.


Second, don’t install any files to {pf}, {win}, {sys}, or other system paths. DLL dependencies can be installed to the installation path.


Third, the installer should detect whether it is running as an elevated admin user and default the installation path under Program Files if it is or a user-writeable path if not. This can be done by using a DefaultDirName in the [Setup] section like this:

DefaultDirName={code:DefDirRoot}\AppName

and a [Code] section like this:

[Code]
function IsRegularUser(): Boolean;
begin
Result := not (IsAdminLoggedOn or IsPowerUserLoggedOn);
end;

function DefDirRoot(Param: String): String;
begin
if IsRegularUser then
Result := ExpandConstant('{localappdata}')
else
Result := ExpandConstant('{pf}')
end;


Fourth, any [Registry] entries written under HKLM will fail if the installer is run by a non-admin/elevated user and should be marked to ignore failure by adding the noerror flag. And if possible and appropriate, add the equivalent HKCU registry entries, which will work on a non-admin installation.


Finally, non-admin users do not have permissions to register COM DLLs and OCXs. One option, which is not recommended, is to also register in user-level registry locations. A better option where possible is to utilize Registry-Free COM.


[출처]

http://www.kinook.com/blog/?p=53