This website uses cookies. By clicking Accept, you consent to the use of cookies. Click Here to learn more about how we use cookies.
Turn on suggestions
Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
- Revenera Community
- :
- InstallAnywhere
- :
- InstallAnywhere Forum
- :
- Enforce Administrator privileges for Installer Execution
Subscribe
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Subscribe
- Mute
- Printer Friendly Page
‎Aug 02, 2010
07:41 AM
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?
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?
(4) Replies
‎Aug 03, 2010
05:21 PM
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"
[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"
‎Aug 05, 2010
07:49 AM
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.
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.
‎Aug 06, 2010
12:03 AM
Ok, got it.
You need to include services.jar under $IA_HOME/resource/services.
The code works fine.
Thanks a lot.
You need to include services.jar under $IA_HOME/resource/services.
The code works fine.
Thanks a lot.