对于Inno Setup,忽略空目录可以通过在脚本中设置“Skipifsilent”参数来实现。具体步骤如下:
以下是一个示例脚本:
[Setup]
AppId=1D7A5470-942F-4649-8B69-122888AB0BA5
AppVersion=1.0.0+1
AppName=MyApp
AppPublisher=Me
AppPublisherURL=https://www.example.com
AppSupportURL=https://www.example.com
AppUpdatesURL=https://www.example.com
DefaultDirName={autopf64}\MyApp
DisableProgramGroupPage=yes
OutputDir=.
OutputBaseFilename=setup
Compression=lzma
SolidCompression=yes
SetupIconFile=
WizardStyle=modern
PrivilegesRequired=none
ArchitecturesAllowed=x64
ArchitecturesInstallIn64BitMode=x64
Skipifsilent=1
[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"
[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
Name: "launchAtStartup"; Description: "{cm:AutoStartProgram,}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
[Files]
Source: "C:\path-to-your-software\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
; NOTE: Don't use "Flags: ignoreversion" on any shared system files
[Icons]
Name: "{autoprograms}\"; Filename: "{app}\your-main-executable.exe"
Name: "{autodesktop}\"; Filename: "{app}\your-main-executable.exe"; Tasks: desktopicon
Name: "{userstartup}\"; Filename: "{app}\your-main-executable.exe"; WorkingDir: "{app}"; Tasks: launchAtStartup
[Run]
Filename: "{app}\your-main-executable.exe"; Description: "{cm:LaunchProgram,}"; Flags: nowait postinstall skipifsilent
这个示例脚本将创建一个带有桌面图标和用户启动菜单项的软件。在安装过程中,如果目录为空,则不会在目标目录中创建任何子目录。在安装完成后,将在目标目录中创建一个名为“{autopf64}\MyApp”的目录,并将安装程序的可执行文件放入其中。
领取专属 10元无门槛券
手把手带您无忧上云