首页 > 其他分享 >Inno Setup

Inno Setup

时间:2023-05-16 14:14:08浏览次数:75  
标签:begin exe end AppName Setup Inno false app

modpath.iss

// ----------------------------------------------------------------------------
//
// Inno Setup Ver:	5.4.2
// Script Version:	1.4.2
// Author:			Jared Breland <[email protected]>
// Homepage:		http://www.legroom.net/software
// License:			GNU Lesser General Public License (LGPL), version 3
//						http://www.gnu.org/licenses/lgpl.html
//
// Script Function:
//	Allow modification of environmental path directly from Inno Setup installers
//
// Instructions:
//	Copy modpath.iss to the same directory as your setup script
//
//	Add this statement to your [Setup] section
//		ChangesEnvironment=true
//
//	Add this statement to your [Tasks] section
//	You can change the Description or Flags
//	You can change the Name, but it must match the ModPathName setting below
//		Name: modifypath; Description: &Add application directory to your environmental path; Flags: unchecked
//
//	Add the following to the end of your [Code] section
//	ModPathName defines the name of the task defined above
//	ModPathType defines whether the 'user' or 'system' path will be modified;
//		this will default to user if anything other than system is set
//	setArrayLength must specify the total number of dirs to be added
//	Result[0] contains first directory, Result[1] contains second, etc.
//		const
//			ModPathName = 'modifypath';
//			ModPathType = 'user';
//
//		function ModPathDir(): TArrayOfString;
//		begin
//			setArrayLength(Result, 1);
//			Result[0] := ExpandConstant('{app}');
//		end;
//		#include "modpath.iss"
// ----------------------------------------------------------------------------

procedure ModPath();
var
	oldpath:	String;
	newpath:	String;
	updatepath:	Boolean;
	pathArr:	TArrayOfString;
	aExecFile:	String;
	aExecArr:	TArrayOfString;
	i, d:		Integer;
	pathdir:	TArrayOfString;
	regroot:	Integer;
	regpath:	String;

begin
	// Get constants from main script and adjust behavior accordingly
	// ModPathType MUST be 'system' or 'user'; force 'user' if invalid
	//if ModPathType = 'system' then begin
	//	regroot := HKEY_LOCAL_MACHINE;
	//	regpath := 'SYSTEM\CurrentControlSet\Control\Session Manager\Environment';
	//end else begin
	//	regroot := HKEY_CURRENT_USER;
	//	regpath := 'Environment';
	//end;
	if IsAdmin then begin
		regroot := HKEY_LOCAL_MACHINE;
		regpath := 'SYSTEM\CurrentControlSet\Control\Session Manager\Environment';
	end else begin
		regroot := HKEY_CURRENT_USER;
		regpath := 'Environment';
	end;

	// Get array of new directories and act on each individually
	pathdir := ModPathDir();
	for d := 0 to GetArrayLength(pathdir)-1 do begin
		updatepath := true;

		// Modify WinNT path
		if UsingWinNT() = true then begin

			// Get current path, split into an array
			RegQueryStringValue(regroot, regpath, 'Path', oldpath);
			oldpath := oldpath + ';';
			i := 0;

			while (Pos(';', oldpath) > 0) do begin
				SetArrayLength(pathArr, i+1);
				pathArr[i] := Copy(oldpath, 0, Pos(';', oldpath)-1);
				oldpath := Copy(oldpath, Pos(';', oldpath)+1, Length(oldpath));
				i := i + 1;

				// Check if current directory matches app dir
				if pathdir[d] = pathArr[i-1] then begin
					// if uninstalling, remove dir from path
					if IsUninstaller() = true then begin
						continue;
					// if installing, flag that dir already exists in path
					end else begin
						updatepath := false;
					end;
				end;

				// Add current directory to new path
				if i = 1 then begin
					newpath := pathArr[i-1];
				end else begin
					newpath := newpath + ';' + pathArr[i-1];
				end;
			end;

			// Append app dir to path if not already included
			if (IsUninstaller() = false) AND (updatepath = true) then
				newpath := newpath + ';' + pathdir[d];

			// Write new path
			RegWriteStringValue(regroot, regpath, 'Path', newpath);

		// Modify Win9x path
		end else begin

			// Convert to shortened dirname
			pathdir[d] := GetShortName(pathdir[d]);

			// If autoexec.bat exists, check if app dir already exists in path
			aExecFile := 'C:\AUTOEXEC.BAT';
			if FileExists(aExecFile) then begin
				LoadStringsFromFile(aExecFile, aExecArr);
				for i := 0 to GetArrayLength(aExecArr)-1 do begin
					if IsUninstaller() = false then begin
						// If app dir already exists while installing, skip add
						if (Pos(pathdir[d], aExecArr[i]) > 0) then
							updatepath := false;
							break;
					end else begin
						// If app dir exists and = what we originally set, then delete at uninstall
						if aExecArr[i] = 'SET PATH=%PATH%;' + pathdir[d] then
							aExecArr[i] := '';
					end;
				end;
			end;

			// If app dir not found, or autoexec.bat didn't exist, then (create and) append to current path
			if (IsUninstaller() = false) AND (updatepath = true) then begin
				SaveStringToFile(aExecFile, #13#10 + 'SET PATH=%PATH%;' + pathdir[d], True);

			// If uninstalling, write the full autoexec out
			end else begin
				SaveStringsToFile(aExecFile, aExecArr, False);
			end;
		end;
	end;
end;

// Split a string into an array using passed delimeter
procedure MPExplode(var Dest: TArrayOfString; Text: String; Separator: String);
var
	i: Integer;
begin
	i := 0;
	repeat
		SetArrayLength(Dest, i+1);
		if Pos(Separator,Text) > 0 then	begin
			Dest[i] := Copy(Text, 1, Pos(Separator, Text)-1);
			Text := Copy(Text, Pos(Separator,Text) + Length(Separator), Length(Text));
			i := i + 1;
		end else begin
			 Dest[i] := Text;
			 Text := '';
		end;
	until Length(Text)=0;
end;


procedure CurStepChanged(CurStep: TSetupStep);
var
	taskname:	String;
begin
	taskname := ModPathName;
	if CurStep = ssPostInstall then
		if WizardIsTaskSelected(taskname) then
			ModPath();
end;

procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
var
	aSelectedTasks:	TArrayOfString;
	i:				Integer;
	taskname:		String;
	regpath:		String;
	regstring:		String;
	appid:			String;
begin
	// only run during actual uninstall
	if CurUninstallStep = usUninstall then begin
		// get list of selected tasks saved in registry at install time
		appid := '{#emit SetupSetting("AppId")}';
		if appid = '' then appid := '{#emit SetupSetting("AppName")}';
		regpath := ExpandConstant('Software\Microsoft\Windows\CurrentVersion\Uninstall\'+appid+'_is1');
		RegQueryStringValue(HKLM, regpath, 'Inno Setup: Selected Tasks', regstring);
		if regstring = '' then RegQueryStringValue(HKCU, regpath, 'Inno Setup: Selected Tasks', regstring);

		// check each task; if matches modpath taskname, trigger patch removal
		if regstring <> '' then begin
			taskname := ModPathName;
			MPExplode(aSelectedTasks, regstring, ',');
			if GetArrayLength(aSelectedTasks) > 0 then begin
				for i := 0 to GetArrayLength(aSelectedTasks)-1 do begin
					if comparetext(aSelectedTasks[i], taskname) = 0 then
						ModPath();
				end;
			end;
		end;
	end;
end;

function NeedRestart(): Boolean;
var
	taskname:	String;
begin
	taskname := ModPathName;
	if WizardIsTaskSelected(taskname) and not UsingWinNT() then begin
		Result := True;
	end else begin
		Result := False;
	end;
end;

inno.iss

#define AppName "FFmpeg"
#define AppVersion "4.3.1"
#define AppCopyright "Copyright ?2020 ffmpeg.org"
#define AppPublisher "https://ffmpeg.org/"
#define AppUrl "https://ffmpeg.org/"
#define AppEmail "[email protected]"
#define InstallBuilder "ProjectSoft"
#define InstallBuilderUrl "https://projectsoft.ru/"

[Setup]
AppId={{11111111-1111-1111-1111-111111111111}}
AppName={#AppName}
AppVersion={#AppVersion}
AppCopyright={#AppCopyright}
AppMutex={#AppName}
AppPublisher={#AppPublisher}
AppPublisherURL={#AppUrl}
AppSupportURL={#AppUrl}
AppContact={#AppEmail}
AppComments={#AppName}

VersionInfoVersion={#AppVersion}
VersionInfoCompany={#AppName}
VersionInfoDescription={#AppName}
VersionInfoTextVersion={#AppVersion}
VersionInfoCopyright={#AppCopyright}
DefaultDirName={autopf}\ffmpeg
DefaultGroupName={#AppName} 

;Compression=none
SolidCompression=yes
Compression=lzma2/ultra64
LZMAUseSeparateProcess=yes
LZMADictionarySize=1048576
LZMANumFastBytes=273

OutputDir=installer
OutputBaseFilename=ffmpeg_install

WizardImageFile=iss/wizard.bmp
WizardSmallImageFile=iss/icon.bmp

SetupIconFile=iss/ffmpeg.ico
UninstallDisplayName=Uninstall {#AppName}
UninstallDisplayIcon={app}/unins000.exe

DisableWelcomePage=False
DisableReadyPage=False
DisableReadyMemo=true
DisableFinishedPage=false
FlatComponentsList=false
AlwaysShowComponentsList=false
ShowComponentSizes=false
WindowShowCaption=false
WindowResizable=false
UsePreviousAppDir=false
UsePreviousGroup=false
AppendDefaultDirName=false
BackSolid=true
WindowStartMaximized=false
DisableProgramGroupPage=true
DisableDirPage=false
ShowLanguageDialog=no

VersionInfoProductName={#AppName}
VersionInfoProductVersion={#AppVersion}
VersionInfoProductTextVersion={#AppName} v{#AppVersion}

ArchitecturesAllowed= x64 
ArchitecturesInstallIn64BitMode=x64

PrivilegesRequiredOverridesAllowed=       dialog 
PrivilegesRequired=lowest 
ChangesEnvironment=yes

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

[CustomMessages]
chs.AddaPathMessage=在系统变量path中添加应用程序的路径(推荐)

[Files]
;Source: iss\ffmpeg.ico; DestDir: {app}; DestName: ffmpeg.ico; Flags: deleteafterinstall
; Place all x64 files here
Source: bin\win64\ffmpeg.exe; DestDir: {app}; DestName: ffmpeg.exe; Check: Is64BitInstallMode        ; Flags: ignoreversion uninsremovereadonly
Source: bin\win64\ffplay.exe; DestDir: {app}; DestName: ffplay.exe; Check: Is64BitInstallMode             ; Flags: ignoreversion uninsremovereadonly
Source: bin\win64\ffprobe.exe; DestDir: {app}; DestName: ffprobe.exe; Check: Is64BitInstallMode            ; Flags: ignoreversion uninsremovereadonly
; Place all x86 files here, first one should be marked 'solidbreak'
;Source: bin\win32\ffmpeg.exe; DestDir: {app}; DestName: ffmpeg.exe; Check: not Is64BitInstallMode; Flags: solidbreak
;Source: bin\win32\ffplay.exe; DestDir: {app}; DestName: ffplay.exe; Check: not Is64BitInstallMode; Flags: solidbreak
;Source: bin\win32\ffprobe.exe; DestDir: {app}; DestName: ffprobe.exe; Check: not Is64BitInstallMode; Flags: solidbreak

[Tasks]
Name: add_ffmpeg_path; Description: "{cm:AddaPathMessage}"
Name: "DesktopIcon"; Description: "创建桌面快捷方式图标" ; Flags: unchecked

[Registry]
Root: HKLM; Subkey: "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"; ValueType: expandsz; ValueName: "Path"; ValueData: "{olddata};{app}"    ;Check : IsAdmin
Root: HKCU; Subkey: "Environment"; ValueType: expandsz; ValueName: "Path"; ValueData: "{olddata};{app}" ;Check: not IsAdmin

[Icons]
Name: "{group}\{cm:UninstallProgram,{#AppName}}"; Filename: "{uninstallexe}";
Name: "{autodesktop}\ffmpeg"; Filename: "{app}\ffmpeg.exe"; WorkingDir: "{app}"; Tasks: DesktopIcon

[Run]
Filename: "{sys}\rundll32.exe"; WorkingDir: "{sys}"; Parameters: "user32.dll,UpdatePerUserSystemParameters"; StatusMsg: "Registering Module...";
[UninstallRun]
Filename: "{sys}\rundll32.exe"; WorkingDir: "{sys}"; Parameters: "user32.dll,UpdatePerUserSystemParameters"; StatusMsg: "Registering Module...";

[Code]

const
	ModPathName = 'add_ffmpeg_path';

function ModPathDir(): TArrayOfString;
begin
	setArrayLength(Result, 1)
	Result[0] := ExpandConstant('{app}');
end;

#include "modpath.iss"

#define AppName "12345"
#define AppVersion "10.1.0.8899"
#define AppCopyright "Copyright ?2020 www.12345.com/"
#define AppPublisher "https://www.12345.com/"
#define AppUrl "https://www.12345.com/"
#define AppEmail "[email protected]"
#define InstallBuilder "ProjectSoft"
#define InstallBuilderUrl "https://projectsoft.ru/"

[Setup]
AppId={{11111111-1111-1111-1111-111111111111}}
AppName={#AppName}
AppVersion={#AppVersion}
AppCopyright={#AppCopyright}
AppMutex={#AppName}
AppPublisher={#AppPublisher}
AppPublisherURL={#AppUrl}
AppSupportURL={#AppUrl}
AppContact={#AppEmail}
AppComments={#AppName}

VersionInfoVersion={#AppVersion}
VersionInfoCompany={#AppName}
VersionInfoDescription={#AppName}
VersionInfoTextVersion={#AppVersion}
VersionInfoCopyright={#AppCopyright}
DefaultDirName={autopf}\{#AppName} 
DefaultGroupName={#AppName} 

;Compression=none
SolidCompression=yes
Compression=lzma2/ultra64
LZMAUseSeparateProcess=yes
LZMADictionarySize=1048576
LZMANumFastBytes=273

OutputDir=installer
OutputBaseFilename={#AppName}_install

WizardImageFile=iss/wizard.bmp
WizardSmallImageFile=iss/icon.bmp

SetupIconFile=iss/setup.ico
UninstallDisplayName=Uninstall {#AppName}
UninstallDisplayIcon={app}/unins000.exe

DisableWelcomePage=False
DisableReadyPage=False
DisableReadyMemo=true
DisableFinishedPage=false
FlatComponentsList=false
AlwaysShowComponentsList=false
ShowComponentSizes=false
WindowShowCaption=false
WindowResizable=false
UsePreviousAppDir=false
UsePreviousGroup=false
AppendDefaultDirName=false
BackSolid=true
WindowStartMaximized=false
DisableProgramGroupPage=true
DisableDirPage=false
ShowLanguageDialog=no

VersionInfoProductName={#AppName}
VersionInfoProductVersion={#AppVersion}
VersionInfoProductTextVersion={#AppName} v{#AppVersion}

ArchitecturesAllowed= x64 
ArchitecturesInstallIn64BitMode=x64

;PrivilegesRequiredOverridesAllowed=       dialog 
;PrivilegesRequired=lowest 

PrivilegesRequired=admin
ChangesEnvironment=yes

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

[CustomMessages]
chs.AddaPathMessage=在系统变量path中添加应用程序的路径(推荐)

[Files]
;Source: iss\ffmpeg.ico; DestDir: {app}; DestName: ffmpeg.ico; Flags: deleteafterinstall
; Place all x64 files here
;Source: bin\win64\ffmpeg.exe; DestDir: {app}; DestName: ffmpeg.exe; Check: Is64BitInstallMode        ; Flags: ignoreversion uninsremovereadonly
;Source: bin\win64\ffplay.exe; DestDir: {app}; DestName: ffplay.exe; Check: Is64BitInstallMode             ; Flags: ignoreversion uninsremovereadonly
;Source: bin\win64\ffprobe.exe; DestDir: {app}; DestName: ffprobe.exe; Check: Is64BitInstallMode            ; Flags: ignoreversion uninsremovereadonly
; Place all x86 files here, first one should be marked 'solidbreak'
;Source: bin\win32\ffmpeg.exe; DestDir: {app}; DestName: ffmpeg.exe; Check: not Is64BitInstallMode; Flags: solidbreak
;Source: bin\win32\ffplay.exe; DestDir: {app}; DestName: ffplay.exe; Check: not Is64BitInstallMode; Flags: solidbreak
;Source: bin\win32\ffprobe.exe; DestDir: {app}; DestName: ffprobe.exe; Check: not Is64BitInstallMode; Flags: solidbreak
Source: "bin\*"; DestDir: {app}; Flags: recursesubdirs createallsubdirs ignoreversion uninsremovereadonly

[Tasks]
Name: add_ffmpeg_path; Description: "{cm:AddaPathMessage}"
;Name: "DesktopIcon"; Description: "创建桌面快捷方式图标" ; Flags: unchecked
Name: "DesktopIcon"; Description: "创建桌面快捷方式图标" ; 

[Registry]
Root: HKLM; Subkey: "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"; ValueType: expandsz; ValueName: "Path"; ValueData: "{olddata};{app}"    ;Check : IsAdmin
Root: HKCU; Subkey: "Environment"; ValueType: expandsz; ValueName: "Path"; ValueData: "{olddata};{app}" ;Check: not IsAdmin
Root: HKLM; Subkey: "SOFTWARE\12345Pic";Flags: uninsdeletekey
Root: HKLM; Subkey: "SOFTWARE\WOW6432Node\12345Pic";Flags: uninsdeletekey
Root: HKCU; Subkey: "Software\12345.com";Flags: uninsdeletekeyifempty
Root: HKLM; Subkey: "SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\12345Viewer.exe";Flags: uninsdeletekey
Root: HKLM; Subkey: "SOFTWARE\RegisteredApplications" ;ValueName: "12345Pic";Flags: uninsdeletevalue

[Icons]
Name: "{group}\{cm:UninstallProgram,{#AppName}}"; Filename: "{uninstallexe}";
Name: "{autodesktop}\12345"; Filename: "{app}\12345Viewer.exe"; WorkingDir: "{app}"; Tasks: DesktopIcon

[Run]
Filename: "{app}\12345Loader.exe"; WorkingDir: "{app}"; Parameters: "-install"; StatusMsg: "Registering Module...";
Filename: "{sys}\rundll32.exe"; WorkingDir: "{app}"; Parameters: "/s,12345Thumb.dll"; StatusMsg: "Registering Module..."; Check: not Is64BitInstallMode
Filename: "{sys}\rundll32.exe"; WorkingDir: "{app}"; Parameters: "/s,12345Thumb64.dll"; StatusMsg: "Registering Module..."; Check: Is64BitInstallMode
Filename: "{sys}\rundll32.exe"; WorkingDir: "{sys}"; Parameters: "user32.dll,UpdatePerUserSystemParameters"; StatusMsg: "Registering Module...";
[UninstallRun]
Filename: "{app}\12345Loader.exe"; WorkingDir: "{app}"; Parameters: "-preUninstall"; StatusMsg: "Registering Module...";
Filename: "{app}\12345Loader.exe"; WorkingDir: "{app}"; Parameters: "-uninstall"; StatusMsg: "Registering Module...";
Filename: "{sys}\rundll32.exe"; WorkingDir: "{app}"; Parameters: "/s,/u,12345Thumb.dll"; StatusMsg: "Registering Module..."; Check: not Is64BitInstallMode
Filename: "{sys}\rundll32.exe"; WorkingDir: "{app}"; Parameters: "/s,/u,12345Thumb64.dll"; StatusMsg: "Registering Module..."; Check: Is64BitInstallMode
Filename: "{sys}\rundll32.exe"; WorkingDir: "{sys}"; Parameters: "user32.dll,UpdatePerUserSystemParameters"; StatusMsg: "Registering Module...";

[Code]

const
	ModPathName = 'add_ffmpeg_path';

function ModPathDir(): TArrayOfString;
begin
	setArrayLength(Result, 1)
	Result[0] := ExpandConstant('{app}');
end;

#include "modpath.iss"

标签:begin,exe,end,AppName,Setup,Inno,false,app
From: https://www.cnblogs.com/yzpopulation/p/17140605.html

相关文章

  • ERROR: Command errored out with exit status 1: python setup.py egg_info Check th
     001、在利用python2.7环境下利用pip安装pyfaidx模块时报如下错误:ERROR:Commanderroredoutwithexitstatus1:pythonsetup.pyegg_infoCheckthelogsforfullcommandoutput. 002、查看pip版本[root@PC1pip]#pip--versionpip20.3.4from/usr/lib/pyth......
  • ChatGPT Plugin开发setup - Java(Spring Boot) Python(fastapi)
    记录一下快速模板,整体很简单,如果不接auth,只需要以下:提供一个/.well-known/ai-plugin.json接口,返回openAI所需要的格式提供openAPI规范的文档CORS设置其他的和普通的web开发类似.本地开发就直接使用localhost即可,前几天官方localhost无法联通,最近应该修复了.要让GPT......
  • MySQL的varchar存储原理:InnoDB记录存储结构
    摘要:varchar(M)能存多少个字符,为什么提示最大16383?innodb怎么知道varchar真正有多长?记录为NULL,innodb如何处理?某个列数据占用的字节数非常多怎么办?影响每行实际可用空间的因素有哪些?本篇围绕innodb默认行格式dynamic来说说原理。本文分享自华为云社区《MySQL的varchar水真的太深......
  • 如何利用NTSETUP安装系统
    用NTSETUP装系统此教程适用于安装WindowsVista以上系统。目录用NTSETUP装系统下载启动和安装下载https://pan.huang1111.cn/s/1gKzuv启动和安装选择下载的镜像和引导驱动器镜像可以选择ISO镜像下\source\boot.wim或\source\install.wim,也可以直接选择ISO镜像,他会挂载......
  • vue3 setup 父页面调用子组件及子组件调用父页面方法的DEMO
    父页面调用子组件中方法父页面<template><div><!--第四步:页面使用子组件,并添加ref属性,注意ref属性不能和子组件重名--><role-cardref="roleRef"></role-card></div></template><scriptlang="ts"setup>import{ref......
  • Understanding Preclinical Research: The Key to Successful Innovative Drug Develo
    Thefirstchallengeindrugdevelopmentispreclinicalresearchofnewdrugs,whichreferstochemicalsynthesisornaturalproductpurificationstudies,druganalysisstudies,pharmacodynamics,pharmacokinetics,toxicology,andpharmacologystudiesperfo......
  • Java Test ENV setup for Algorithms, 4th Edition
    setjavaenv,add/home/linxu/myspace/java_projects/algs4/algs4.jartoCLASSPATHsudovim~/.bashrcexportJAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64exportPATH=$PATH:$JAVA_HOME/binexportCLASSPATH=$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/dt.jar:$JAVA_......
  • Setup passwordless between servers by manual
    陷阱Linux7开始,默认在selinux级别上都有所增强,特别对于.ssh文件的上下文属性必须是ssh_home_t,否则导致其他权限都正确的情况下,passwordlessssh还是会失败。1.Configthessh-/etc/ssh/ssh_config#-ensurethecorrectvaluesforthefollowingparametersPassword......
  • MySQL 8.0中InnoDB buffer pool size进度更透明
    GreatSQL社区原创内容未经授权不得随意使用,转载请联系小编并注明来源。GreatSQL是MySQL的国产分支版本,使用上与MySQL一致。作者:Yejinrong/叶金荣文章来源:GreatSQL社区原创MySQL8.0upupup~从MySQL5.7开始,支持在线动态调整innodbbufferpool,并为此新增了一个状态变......
  • 存储引擎Myisam和Innodb的区别
    Yyisam存储:如果表对事务要求不高,同时是以查询和添加为主的,我们考虑使用myisam存储引擎InnoDB存储:对事务要求高,保存的数据都是重要数据,我们建议使用INN0DB,比如订单表,账号表.总结1.事务安全2.查询和添加速度3.支持全文索引4.锁机制5.外键MyISAM不支持外键,INNODB支持外键.......