I pro-test -inno setup package EXE (more complete example)

; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
#define MyAppName "消息助手"
#define MyAppVersion "1.0"
#define MyAppPublisher "消息助手, Inc."
#define MyAppURL "http://www.newhero.com.cn/"
#define MyAppExeName "消息助手.exe"

[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.)
; 打包时需要生成一个新的GUID(UUID uuid = UUID.randomUUID();System.out.println(uuid);)
AppId={{85773db6-6d50-40ad-9371-c0f603bb1f31}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={pf}\{#MyAppName}
DisableProgramGroupPage=yes
OutputBaseFilename=消息助手
;默认开始菜单名
DefaultGroupName=消息助手
Compression=lzma
SolidCompression=yes
DisableFinishedPage=yes
AlwaysRestart=no

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

[Files]
Source: "E:\innosetup\*"; DestDir: "{app}"; Flags: ignoreversion
Source: "E:\innosetup\kpsignx.dll"; DestDir: "C:\Windows\System32"; Flags: ignoreversion
Source: "E: \ InnoSetup \ kpsignx.dll"; DestDir: "C: \ Windows \ SysWOW64"; Flags: ignoreversion
; NOTE: the Do not use "Flags: ignoreversion" ON the any Shared System Files

[Icons]
the Name: " {userdesktop} \ message assistant "; Filename:" {app} \ message assistant .exe "; IconFileName:" {} App \ the favicon.ico "
the Name:" {Group} \ message assistant "; Filename:" {app} \ message Assistant .exe ";
the Name:" {Group} \ uninstall message assistant "; Filename:" {} App \ the unins000.exe "

[the Run]
; Filename:" App {} \ {#} MyAppExeName "; the Flags: nowait a postinstall skipifsilent
Filename: "{} App \ kpsignx.bat"; the Parameters: "- Open"

; custom text in different languages
[CustomMessages]
chinesesimp.checkSoftTip = installation detects that the software to be installed is running! % n% n Click "OK" to continue after termination of the software, otherwise click "


 

  KDetectSoft function (strExeName: String): Boolean;
  // variable definition
  var ErrorCode: Integer;
  var bRes: Boolean;
  var strFileContent: AnsiString;
  var strTmpPath: String; // temporary directory
  var strTmpFile: String; // temporary files, save Find software data results
  var strCmdFind: String; // Find software command
  var strCmdKill: String; // software command terminates
  the begin
    strTmpPath: GetTempDir = ();
    strTmpFile: = the Format ( '% sfindSoftRes.txt', [strTmpPath]);
    strCmdFind: = the Format ( '/ C tasklist / NH | Find / C / I "% S"> "% S"', [strExeName, strTmpFile]);
    strCmdKill: = the Format ( '/ C the taskkill / F / T / IM% S ', [strExeName]);
    //ShellExec('open', ExpandConstant('{cmd}'), '/c taskkill /f /t /im 你的软件名.exe', '', SW_HIDE, ewNoWait, ErrorCode);
    //bRes := ShellExec('open', ExpandConstant('{cmd}'), '/c tasklist /nh|find /c /i "你的软件名.exe" > 0.txt', '', SW_HIDE, ewWaitUntilTerminated, ErrorCode);
    bRes := ShellExec('open', ExpandConstant('{cmd}'), strCmdFind, '', SW_HIDE, ewWaitUntilTerminated, ErrorCode);
    if bRes then begin
        bRes := LoadStringFromFile(strTmpFile, strFileContent);
        strFileContent := Trim(strFileContent);
        if bRes then begin
           if StrToInt(strFileContent) > 0 then begin
              if MsgBox(ExpandConstant('{cm:} checkSoftTip '), mbConfirmation, MB_OKCANCEL) = the then IDOK the begin
               // terminate the program
               ShellExec ( 'Open', ExpandConstant ( '{} cmd'), strCmdKill, '', SW_HIDE, ewNoWait, the ErrorCode);
               the Result: = to true; // continue the installation
              End the else the begin
               the Result: = to false; // Setup Exit
               Exit ;
              End;
           End the else the begin
              // MsgBox ( 'software is not running', mbInformation, MB_OK);
              the Result: = to true;
              the Exit;
           End;
        End;
    End;
    the Result: = to true;
  End;  
   
        
  closed when the software // unloading
  function InitializeUninstall (): Boolean;
  the begin
    the Result: = KDetectSoft ( 'helper message .exe');
  End;

// installation package Baidu search inno setup download it, finished the chinesesimp.isl files on Languages ​​following can be finished (this is for the finished package after package installation package is finished, this software is not finished package)

Guess you like

Origin www.cnblogs.com/luyue1995/p/11698822.html