• Innosetup


    卸载的同时删除日志,卸载的时候判断程序是否正在运行,regsvr32

    1.卸载程序的时候如何判断程序是否正在运行

    http://bbs.csdn.net/topics/370097914

     2.强制删除安装目录

    http://blog.csdn.net/cnbata/article/details/6289031

     3.注册以及注销ocx控件

    http://blog.csdn.net/orion_04/article/details/1676976

    http://www.jrsoftware.org/ishelp/index.php?topic=isxfunc_registerserver

    Flags:

    restartreplace

    When an existing file needs to be replaced, and it is in use (locked) by another running process, Setup will by default display an error message.

    This flag tells Setup to instead register the file to be replaced the next time the system is restarted (by calling MoveFileEx or by creating an entry in WININIT.INI).

    When this happens, the user will be prompted to restart their computer at the end of the installation process.

    NOTE: This flag has no effect if the user does not have administrative privileges.

    Therefore, when using this flag, it is recommended that you leave the PrivilegesRequired [Setup] section directive at the default setting of admin.

    regserver

    Register the DLL/OCX file.

    With this flag set, Setup will call the DllRegisterServer function exported by the DLL/OCX file, and the uninstaller will call DllUnregisterServer prior to removing the file.

    When used in combination with sharedfile, the DLL/OCX file will only be unregistered when the reference count reaches zero.

    On a 64-bit mode install, the file is assumed to be a 64-bit image and will be registered inside a 64-bit process.

    You can override this by specifying the 32bit flag.

    See the Remarks at the bottom of this topic for more information.

    安装前卸载之前的版本

    http://stackoverflow.com/questions/2000296/innosetup-how-to-automatically-uninstall-previous-installed-version

    I have used the following. I'm not sure it's the simplest way to do it but it works.

    This uses {#emit SetupSetting("AppId")} which relies on the Inno Setup Preprocessor. If you don't use that, cut-and-paste your App ID in directly.

    下面的代码,是Pascal Script

    /////////////////////////////////////////////////////////////////////
    function GetUninstallString(): String;
    var
      sUnInstPath: String;
      sUnInstallString: String;
    begin
      sUnInstPath := ExpandConstant('SoftwareMicrosoftWindowsCurrentVersionUninstall{#emit SetupSetting("AppId")}_is1');
      sUnInstallString := '';
      if not RegQueryStringValue(HKLM, sUnInstPath, 'UninstallString', sUnInstallString) then
        RegQueryStringValue(HKCU, sUnInstPath, 'UninstallString', sUnInstallString);
      Result := sUnInstallString;
    end;
    
    
    /////////////////////////////////////////////////////////////////////
    function IsUpgrade(): Boolean;
    begin
      Result := (GetUninstallString() <> '');
    end;
    
    
    /////////////////////////////////////////////////////////////////////
    function UnInstallOldVersion(): Integer;
    var
      sUnInstallString: String;
      iResultCode: Integer;
    begin
    // Return Values:
    // 1 - uninstall string is empty
    // 2 - error executing the UnInstallString
    // 3 - successfully executed the UnInstallString
    
      // default return value
      Result := 0;
    
      // get the uninstall string of the old app
      sUnInstallString := GetUninstallString();
      if sUnInstallString <> '' then begin
        sUnInstallString := RemoveQuotes(sUnInstallString);
        if Exec(sUnInstallString, '/SILENT /NORESTART /SUPPRESSMSGBOXES','', SW_HIDE, ewWaitUntilTerminated, iResultCode) then
          Result := 3
        else
          Result := 2;
      end else
        Result := 1;
    end;
    
    /////////////////////////////////////////////////////////////////////
    procedure CurStepChanged(CurStep: TSetupStep);
    begin
      if (CurStep=ssInstall) then
      begin
        if (IsUpgrade()) then
        begin
          UnInstallOldVersion();
        end;
      end;
    end;

    彻底卸载

    http://www.jrsoftware.org/ishelp/index.php?topic=runsection

    贴吧里看到的,如何卸载干净http://tieba.baidu.com/p/3252185393

    [UninstallRun]
    Filename: "{cmd}"; Parameters: "/c rd /s /q ""{app}"""; Flags: hidewizard runhidden

    Filename (Required)
    The program to execute, or file/folder to open.

    If Filename is not an executable (.exe or .com) or batch file (.bat or .cmd), you must use the shellexec flag on the entry. This parameter can include constants.

    Parameters
    Optional command line parameters for the program, which can include constants.

    hidewizard
    If this flag is specified, the wizard will be hidden while the program is running.

    runhidden
    If this flag is specified, it will launch the program in a hidden window. Never use this flag when executing a program that may prompt for user input.

    cmd /c 
    /C Carries out the command specified by the string and then terminates.


    rd命令
    命令说明:rd命令只有2个参数,分别是/s和/q。
    /s参数的作用是除目录本身外,还将删除指定目录下的所有子目录和文件。用于删除目录树。如果不带这个参数就只能删除空文件夹。
    /q参数的作用是安静模式,带/s删除目录树时不需要确认。



    [UninstallDelete]
    Name: {app}; Type: filesandordirs

    Name  (Required)

    Name of the file or directory to delete.

    NOTE: Don't be tempted to use a wildcard here to delete all files in the {app} directory. Doing this is strongly recommend against for two reasons.

    First, users usually don't appreciate having their data files they put in the application directory deleted without warning (they might only be uninstalling it because they want to move it to a different drive, for example). It's better to leave it up to the end users to manually remove them if they want.

    Also, if the user happened to install the program in the wrong directory by mistake (for example, C:WINDOWS) and then went to uninstall it there could be disastrous consequences. So again, DON'T DO THIS!

    Type  (Required)

    filesandordirs

    Functions the same as files except it matches directory names also, and any directories matching the name are deleted including all files and subdirectories in them.

    OnlyBelowVersion

    http://www.jrsoftware.org/ishelp/index.php?topic=setup_onlybelowversion

    Format:  major.minor

    Default value:0

    Description:

    This directive lets you specify a minimum version of Windows that your software will not run on. Specifying "0" means there is no upper version limit. Build numbers and/or service pack levels may be included.

    This directive is essentially the opposite of MinVersion.

    For compatibility with previous versions of Inno Setup, separate Windows 95/98/Me and Windows NT version numbers may be specified, separated by a comma. Example: OnlyBelowVersion=0,6.0. The Windows 95/98/Me version number (the first number) isn't used, however, as Inno Setup no longer supports Windows 95/98/Me.

    Windows Versions

    http://www.jrsoftware.org/ishelp/index.php?topic=winvernotes

    5.0.2195 Windows 2000
    5.1.2600 Windows XP
    or Windows XP 64-Bit Edition Version 2002 (Itanium)
    5.2.3790 Windows Server 2003
    or Windows XP x64 Edition (AMD64/EM64T)
    or Windows XP 64-Bit Edition Version 2003 (Itanium)
    6.0.6000 Windows Vista
    6.0.6001 Windows Vista with Service Pack 1
    or Windows Server 2008
    6.1.7600 Windows 7
    or Windows Server 2008 R2
    6.1.7601 Windows 7 with Service Pack 1
    or Windows Server 2008 R2 with Service Pack 1
    6.2.9200 Windows 8
    or Windows Server 2012
    6.3.9200 Windows 8.1
    or Windows Server 2012 R2
    6.3.9600 Windows 8.1 with Update 1
    10.0.10240 Windows 10

    Note that there is normally no need to specify the build numbers (i.e., you may simply use "6.2" for Windows 8).

  • 相关阅读:
    LeetCode: Reverse Words in a String && Rotate Array
    LeetCode: Maximum Product Subarray && Maximum Subarray &子序列相关
    =new、=null、.clear()、system.gc()的区别
    对象转字符串的效率问题
    Java遍历Map对象的四种方式
    JDK升级
    eclipse的任务列表
    统一修改数据库表名字段大小写
    get传数组
    vue编辑回显问题
  • 原文地址:https://www.cnblogs.com/chucklu/p/6434021.html
Copyright © 2020-2023  润新知