Tom
Tom

Reputation: 6707

How to create a common desktop icon only if setupper is running elevated with admin rights

[ICONS]    
Name: {commondesktop}\{#oemtitle}; Filename: {app}\app.exe; WorkingDir: {app}; IconIndex: 0; Flags: createonlyiffileexists

How to make the above icon only if running elevated, currently my setupper displays an error dialog for this icon when setupper is executed with the lower permissions as I have PrivilegesRequiredOverridesAllowed=dialog that allows end-user to choose to install to themself only.

Upvotes: 1

Views: 250

Answers (1)

Martin Prikryl
Martin Prikryl

Reputation: 202088

Use {autodesktop} constant to create the icon on common desktop when elevated and on user's desktop otherwise.

[Icons]    
Name: {autodesktop}\{#oemtitle}; Filename: {app}\app.exe; ...

To answer your literal question: To create an icon when running elevated only, use Check parameter with IsAdminInstallMode function (or IsAdmin).

[Icons]    
Name: {commondesktop}\{#oemtitle}; Filename: {app}\app.exe; \
    WorkingDir: {app}; IconIndex: 0; Flags: createonlyiffileexists; \
    Check: IsAdminInstallMode

Upvotes: 2

Related Questions