Create desktop link Icon after the Run section of Inno Setup

放肆的年华 提交于 2020-05-14 07:18:40

问题


Overview

My install process involves placing over 2GB of data on a disk. So I use Inno Setup, but I run 7ZIP to actually extract/install the files.

Issue

The issue I have is that it seems the desktop icon is being created before the [Run] section, so there is no icon to set the the desktop link. Is there a way around this? (I have tried both {src} and {app} as the folder to find the icon.)

CODE

[Run]
Filename: "{pf64}\7-zip\7zG.exe"; Parameters: "x ""{src}\GL.7z"" -o""{app}\"" * -r -aoa"; \
  Flags: runascurrentuser

[Icons]
Name: "{group}\EGPL Watson Uninstall"; Filename: "{uninstallexe}"; WorkingDir: "{app}"
Name: "{commondesktop}\DashBoard"; \
  Filename: "{app}\dashboard\node_modules\electron\dist\electron.exe"; \
  WorkingDir: "{app}\dashboard"; IconFilename: "{src}\dashboard\build\configure.ico"; \
  Parameters: "main.js"; AfterInstall: SetElevationBit('{commondesktop}\DashBoard.lnk')

回答1:


A quick and dirty solution is to set ChangesAssociations:

[Setup]
ChangesAssociations=yes

It makes Windows Explorer refresh all icons after the installer finishes.


A clean solution is to create the icon only after the [Run] section using CreateShellLink:

[Run]
Filename: "{pf64}\7-zip\7zG.exe"; \
    Parameters: "x ""{src}\GL.7z"" -o""{app}\"" * -r -aoa"; \
    Flags: runascurrentuser; AfterInstall: CreateIcon
[Code]

procedure CreateIcon;
var
  IconFileName: string;
begin
  IconFileName := ExpandConstant('{commondesktop}\DashBoard.lnk');

  CreateShellLink(
    IconFileName, '',
    ExpandConstant('{app}\dashboard\node_modules\electron\dist\electron.exe'),
    'main.js', ExpandConstant('{app}\dashboard'),
    ExpandContant('{app}\dashboard\build\configure.ico'), 0, SW_SHOWNORMAL);

  SetElevationBit(IconFileName);
end;


来源:https://stackoverflow.com/questions/44076985/create-desktop-link-icon-after-the-run-section-of-inno-setup

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!