Inno Setup 简单安装脚本

; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!

#define MyAppName "XXX软件"
#define MyAppVersion " 1.1.0"
#define MyAppPublisher "XXX有限公司"
#define MyAppURL "http://www.xxx.com/"
#define MyAppExeName "XXX软件.exe"
;MySourcePath 程序所在的文件夹路径
#define MySourcePath "D:\Projects\XXX软件\bin\Release"  

[Setup]
; NOTE: The value of AppId uniquely identifies this application.
; Do not use the same AppId value in installers for other applications.
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
AppId={{B9FB449D-761A-4A35-B874-807E55DBCDD7}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
;DefaultDirName={pf}\{#MyAppName}      默认的安装路径 C:\Program Files
DefaultDirName =D:\XXX软件\
;DisableProgramGroupPage 如果该项设置为 yes, 安装程序将不会显示“选择程序组”向导页。在这种情况下,它将使用由 [Setup] 段的 DefaultGroupName 关键字指定的组名,或者“(Default)”如果没有指定组名的话
DisableProgramGroupPage=yes
;UsePreviousAppDir 是 yes (默认值)并且安装程序发现已经安装了一个相同应用程序的早期版本,它将用先前选择的目录代替默认的目录名称
UsePreviousAppDir=yes
OutputDir=D:\Inno Out Exe
;DisableDirPage 有效值: yes 或 no 默认值: no 说明: 如果该项设置为 yes, 安装程序将不会显示“选择目标文件夹”向导页。在这种情况下,它将始终使用默认的目录名。
DisableDirPage=no
OutputBaseFilename=XXX软件_Ver{#MyAppVersion}
Compression=lzma
SolidCompression=yes
;在控制面板中的显示的卸载信息
Uninstallable=yes
UninstallDisplayName={#MyAppName}{#MyAppVersion}
UninstallDisplayIcon ={#MySourcePath}\ico\Uninstall.ico
;开始菜单中文件夹的名字 , 默认的为Default
DefaultGroupName={#MyAppName}


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

[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked

[Files]
Source: "{#MySourcePath}\{#MyAppExeName}"; DestDir: "{app}"; Flags: ignoreversion
Source: "{#MySourcePath}\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
; NOTE: Don't use "Flags: ignoreversion" on any shared system files  {#MyAppName}

[Icons]
Name: "{group}\{cm:UninstallProgram, }"; Filename: "{uninstallexe}"
Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
Name: "{commondesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon

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

[Files]
Source: "{#MySourcePath}\psvince.dll"; Flags: dontcopy noencryption

[code]

// 安装时判断程序是否正在运行
function IsModuleLoaded(modulename: AnsiString ):  Boolean;
external 'IsModuleLoaded@files:psvince.dll stdcall';
function InitializeSetup():boolean;
var
   IsAppRunning: boolean;
begin
    Result := true;
   begin
    Result:= true;//安装程序继续
    IsAppRunning:= IsModuleLoaded('{#MyAppExeName}');
    while IsAppRunning do
       begin
        if MsgBox('安装程序检测到 {#MyAppExeName} 正在运行!' #13#13 '您必须先关闭它然后单击“确定”继续安装,否则按“取消”退出!', mbConfirmation, MB_OKCANCEL) = IDOK then
         begin
         IsAppRunning:= IsModuleLoaded('{#MyAppExeName}')
         Result:= true;
         end else begin
         IsAppRunning:= false;
         Result:= false; //安装程序退出
         Exit;
         end;
       end;
     end;
end;



您好!以下是一个基本的 Inno Setup 完整安装脚本的示例: ```pascal [Setup] AppName=My Application AppVersion=1.0 DefaultDirName={pf}\My Application DefaultGroupName=My Application OutputDir=userdocs:Inno Setup Examples Output [Files] Source: "C:\Path\To\Your\Files\*"; DestDir: "{app}"; Flags: recursesubdirs [Icons] Name: "{group}\My Application"; Filename: "{app}\YourExecutable.exe" [Run] Filename: "{app}\YourExecutable.exe"; Description: "Launch My Application"; Flags: nowait postinstall ``` 您可以根据您的实际需求进行修改和扩展。这个示例中,您需要将 `AppName`、`AppVersion`、`DefaultDirName` 和 `DefaultGroupName` 替换为您自己的应用程序信息。`OutputDir` 字段指定了安装程序生成的输出目录。 在 `[Files]` 部分,您可以指定要包含在安装程序中的文件和目录。`Source` 字段指定了要复制的文件或目录的路径,而 `DestDir` 字段指定了复制到的目标目录。 `[Icons]` 部分用于创建桌面快捷方式或开始菜单项。在这个示例中,`Name` 字段指定了快捷方式或菜单项的名称,而 `Filename` 字段指定了要启动的可执行文件的路径。 最后,在 `[Run]` 部分,您可以指定在安装完成后需要执行的命令。在这个示例中,我们指定了启动您的应用程序的命令。 请注意,这只是一个简单的示例,您可能需要根据您的实际需求进行更多的自定义和配置。希望对您有所帮助!如果您还有其他问题,请随时提问。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值