cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
richakamal
Level 4

Enforce Administrator privileges for Installer Execution

Hi All,

I have a requirement for installation to be run under administrator privileges.
I selected the option "Administrator" under Project > Platforms > Windows > Windows Execution Level section for my project.
My requirement is that the installer should not proceed at all if there is no required permission level.
But when I run the installer with a non-admin account, the installation proceeds normally and gives an error in the end. I am able to see the product entry in add/remove programs. When I try to uninstall the product, it gives an errror saying unable to uninstall and then removes the entry from the add/remove programs.
Is there any variable which IA populates to let us know the execution rights of the current user or is there any way I can detect this using IA?
Labels (1)
0 Kudos
(4) Replies
pv7721
Level 20

I've got a similar request and personally I use this extremely simple custom code:

[CODE]
package com.company.product.install;

import com.zerog.ia.api.pub.*;
import com.installshield.wizard.service.security.*;
import com.installshield.wizard.service.ServiceException;

public class CheckIfUserHasAdministrativeRights extends CustomCodeAction {

public void install( InstallerProxy installerProxy ) throws InstallException {

SecurityService ss = (SecurityService) installerProxy.getService(SecurityService.class);

try
{
if (ss.isCurrentUserAdmin())
{//The user installing the software has administrative rights
installerProxy.setVariable( "USER_HAS_ADMINISTRATIVE_RIGHTS", "true" );
}
else
{
installerProxy.setVariable( "USER_HAS_ADMINISTRATIVE_RIGHTS", "false" );
}
} catch (ServiceException e) {//Do nothing...
}
return;
}

public void uninstall( UninstallerProxy uninstallerProxy ) throws InstallException {
}

public String getInstallStatusMessage() {
return null;
}

public String getUninstallStatusMessage() {
return null;
}


public static void main( String[] strings ) {

}
}
[/CODE]

There's also a checkbox to check in the Advanced Designer in the Project/Java section, you need to check the "Add support service for custom code"
0 Kudos
richakamal
Level 4

Hi Vlad,

Thank you for the reply. The code looks simple and neat to work with.
But when I try to use the code, I get the compilation error "package com.installshield.wizard.service.security does not exist".
When I checked the IAClasses.zip file, did not find any class for the same.
I could find only 5 class under the package com.installshield.wizard.<>, even though the class com.installshield.wizard.service.security.* is appearing in the Javadocs.
Is there any separate package which we need to download for it?
I am using the IA 2010 Enterprise package.

Thanks,
Richa.
0 Kudos
richakamal
Level 4

Ok, got it.
You need to include services.jar under $IA_HOME/resource/services.
The code works fine.
Thanks a lot.
0 Kudos
pv7721
Level 20

Yes, I've forgot to tell you that you need to add a separate .jar file with the IS interface class, but hopefully you've found that!
0 Kudos