cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
knoepdan
Level 6

Require admin rights for Setup.exe does not work when running Setup.exe from bat file

Hi

In our "Basic MSI" project, I set the "Required Execution Level" attribute to Administrator. (In Media->Releases->Setup.exe).

When i click on the generated Setup.exe, a pop up is displayed that asks for administrative rights. So this works well. However, when i create a batch file that only includes the line "Setup.exe" the installation starts immediately (with prerequisites in our case) and the dialog asking for admin rights is not displayed. (Tested on Windows XP, SP2 and SP3)

Is it because what the information to ask for admin rights is somewhere stored in the Setup.ini file, whose settings are not applied when calling the Setup.exe via bat file? Is there a way to ensure the user is always asked for administrative rights at the beginning of the installation?

Thanks in advance for your answer.
Labels (1)
0 Kudos

(4) Replies
knoepdan
Level 6

Does anyone have an idea?

Thanks in advance and greetings
0 Kudos
Reureu
Level 10

Hi,

I faced the same problem a while ago.
Indeed, setup.exe does not check for administrator rights if it is started from the command line or from a batch file.
Maybe it assumes that only administrators would launch it from a batch file, which is a bit of a silly assumption to me.
On top of that, if a user with no admin credential double-click the MSI file itself, this admin check will be simply bypassed, and the installation/deinstallation will start.
So it is safer to implement this check yourself.

To do this, just read the "AdminUser" MSI property. It tells you if the current user has got administrator credentials.
If this property is set, the user has got admin credentials, and you can react, or display a dialog/message accordingly.

Just one more point: This property just tells you if the user is an administrator of the target PC. It does not tell you if setup.exe was "run as administrator" on Win Vista and Win 7. But it should not be a problem, unless your setup explicitely needs to be "run as administrator".
0 Kudos
knoepdan
Level 6

Hi

I hoped there was a more elegant solution but it does it for me. Thanks for your answer

Greetings
0 Kudos
Reureu
Level 10

The point is:
MSI checks if it can access files for writing at a later stage, if it needs to write/change files during the execute sequence.
So if the end user has no Admin right, and double click the MSI file, it simply bypasses the check implemented in setup.exe, but chances are that MSI returns an error later in the execute sequence.
It is safer to implement the check yourself...
0 Kudos