Inno Setup打包问题汇总

请求的操作需要提升

Inno Setup CreateProcess failed;code 740 请求的操作需要提升

这是因为打包的程序默认需要以管理员身份运行

下载之后打开Resource Hacker,然后打开Inno Setup的安装目录,找到SetupLdr.e32文件,打开。

SetupLdr.e32在InnoSetup的根目录

找到Manifest下的文件打开

找到

1
<requestedExecutionLevel level="asInvoker"  uiAccess="false"/>

改为

1
<requestedExecutionLevel level="requireAdministrator" uiAccess="false"/>

点击F5编译脚本,重新打包运行发现已经不再报错了。

生成快捷方式

新版本6.0.5已经没有该问题了

默认生成的打包的代码是不会生成桌面快捷方式的,所以要想生成桌面快捷方式

Tasks配置段中修改为如下:

1
2
3
[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: checkablealone
Name: "quicklaunchicon"; Description: "{cm:CreateQuickLaunchIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: checkablealone

整体配置大致如下,方便复制修改:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
; 脚本由 Inno Setup 脚本向导 生成!
; 有关创建 Inno Setup 脚本文件的详细资料请查阅帮助文档!

#define MyAppName "星火直播教师端"
#define MyAppDir "xhlive"
#define MyAppVersion "1.3.16"
#define MyAppPublisher "河南星火燎原软件科技有限公司"
#define MyAppURL "http://www.xhkjedu.com/"
#define MyIcoPath "E:\Projects\school_live_client\app.ico"
#define MySourcePath "E:\Projects\school_live_client\dist\win-ia32-unpacked\"
#define MyAppExeName "星火直播教师端.exe"
#define MyTargetPath "D:\程序打包\星火直播教师端\"

[Setup]
; 注: AppId的值为单独标识该应用程序。
; 不要为其他安装程序使用相同的AppId值。
; (若要生成新的 GUID,可在菜单中点击 "工具|生成 GUID"。)
AppId={{3FEF6A45-D0B0-4860-B4BE-9AF53D128F8D}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={autopf}\{#MyAppDir}
DisableProgramGroupPage=yes
; [Icons] 的“quicklaunchicon”条目使用 {userappdata},而其 [Tasks] 条目具有适合 IsAdminInstallMode 的检查。
UsedUserAreasWarning=no
; 以下行取消注释,以在非管理安装模式下运行(仅为当前用户安装)。
;PrivilegesRequired=lowest
OutputDir={#MyTargetPath}
OutputBaseFilename="{#MyAppName}v{#MyAppVersion}"
SetupIconFile="{#MyIcoPath}"
Compression=lzma
SolidCompression=yes
WizardStyle=modern

[Languages]
Name: "chinesesimp"; MessagesFile: "compiler:Default.isl"

[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: checkablealone
Name: "quicklaunchicon"; Description: "{cm:CreateQuickLaunchIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: checkablealone; OnlyBelowVersion: 6.1; Check: not IsAdminInstallMode

[Files]
Source: "{#MySourcePath}{#MyAppExeName}"; DestDir: "{app}"; Flags: ignoreversion
Source: "{#MySourcePath}*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
; 注意: 不要在任何共享系统文件上使用“Flags: ignoreversion”

[Icons]
Name: "{autoprograms}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
Name: "{autodesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon
Name: "{userappdata}\Microsoft\Internet Explorer\Quick Launch\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: quicklaunchicon

[Run]
Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent

文件排除

https://jrsoftware.org/ishelp/index.php?topic=filessection

Specifies a list of patterns to exclude, separated by commas. This parameter cannot be combined with the external flag.

Patterns may include wildcard characters (* and ?). Note that unlike the Source parameter, a simple Unix-style pattern matching routine is used for Excludes.

Dots in the pattern are always significant, thus *.* will not exclude a file with no extension (instead, use just *).

Also, question marks always match exactly one character, thus ?????will not exclude files with names less than five characters long.

If a pattern starts with a backslash (\) it is matched against the start of a path name, otherwise it is matched against the end of a path name. Thus \foo will only exclude a file named foo at the base of the tree. On the other hand, foo will exclude any file named foo anywhere in the tree.

The patterns may include backslashes.

foo\bar will exclude both foo\barand subdir\foo\bar.

\foo\bar will only exclude foo\bar.

Examples:

1
2
Source: "*"; Excludes: "*.~*"
Source: "*"; Excludes: "*.~*,\Temp\*"; Flags: recursesubdirs

忽略配置

1
2
3
[Files]
Source: "{#MySourcePath}{#MyAppExeName}"; DestDir: "{app}"; Flags: ignoreversion
Source: "{#MySourcePath}*"; Excludes: "\db,\temp,\Log,\nginx\html\school,\nginx\html\tongping,app.config,app_service.xml";DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs

注意

多个路径之间用,分割

删除旧的快捷方式

删除旧的快捷方式

1
2
[InstallDelete]
Type: files; Name: "{autodesktop}\星火智慧校园.lnk"

删除安装目录下的文件

1
2
3
[InstallDelete]
Type: files; Name: "{group}\User's Manual (PDF)"
Type: files; Name: "{app}\test.pdf"

其中

  • {autodesktop} 桌面
  • {app} 安装目录
  • {group} 开始菜单

清空图标缓存

如果我们打包时图标设置错了,就算更换了图标重新打包,桌面上的图标还是之前的,这是因为系统图标缓存导致,清空一下图标缓存就行了。

新建 清空图标缓存.bat,用管理员运行即可。

1
2
3
4
5
6
cd /d %userprofile%\AppData\Local\Microsoft\Windows\Explorer 
taskkill /f /im explorer.exe
attrib -h iconcache_*.db
del iconcache_*.db /a
start explorer
pause