需求
使用Inno Setup打包程序之后,很多时候我们需要在安装文件之前卸载原有的程序而不是覆盖安装,本文的Code就是实现了这样的功能。如果想要在安装前先卸载,那么需要加下面代码,需要注意的是双星号里面的 {3FC1FD05-BEC7-430A-B7DB-F07155FDE93E}
部分的改为你们自己的。网上看到有些说_is1前面用AppName,但是我这边不行,下面code中 {3FC1FD05-BEC7-430A-B7DB-F07155FDE93E}
为你的程序名,可以去你的 Inno Setup 脚本中找到程序ID: AppId={
{3FC1FD05-BEC7-430A-B7DB-F07155FDE93E}
也可以到注冊表中确认,为防止以后忘记,在这里记录一下,方便以后使用。
实现原理是:从注冊表 ‘UninstallString’ 项中读取卸载信息,用Exec进行静默卸载。
[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={**{3FC1FD05-BEC7-430A-B7DB-F07155FDE93E}**
AppName={#MyAppName}
AppVersion={#MyAppVersion}
[Code]
f