加
; 加环境变量,开启,下面一行
ChangesEnvironment=yes
和
; 加环境变量wbrj变量名,{app}\project\bin变量值,{app}\后接文件名,{app}表示安装路径。下面一行,{olddata};原来的值上拼接
Root: HKLM; Subkey: “SYSTEM\CurrentControlSet\Control\Session Manager\Environment”; ValueType: string; ValueName: “Path”; ValueData: “{olddata};{app}\project\bin”; Flags: preservestringtype
完成
下面是完整代码
; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
#define MyAppName "万邦软件"
#define MyAppVersion "2.0"
#define MyAppPublisher "dade"
#define MyAppExeName "start.exe"
#define MyAppAssocName MyAppName + " File"
#define MyAppAssocExt ".myp"
#define MyAppAssocKey StringChange(MyAppAssocName, " ", "") + MyAppAssocExt
[Setup]
; 加环境变量,开启,下面一行
ChangesEnvironment=yes
; 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={{75473B0E-602D-4715-BC72-8436F7A2991A}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
DefaultDirName={autopf}\wbrj
ChangesAssociations=yes
DisableProgramGroupPage=yes
; Uncomment the following line to run in non administrative install mode (install for current user only.)
;PrivilegesRequired=lowest
OutputBaseFilename="万邦软件"
Compression=lzma
SolidCompression=yes
WizardStyle=modern
[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"
[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
[Files]
Source: "E:\bushu\dadenb\{#MyAppExeName}"; DestDir: "{app}"; Flags: ignoreversion
Source: "E:\bushu\dadenb\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
; NOTE: Don't use "Flags: ignoreversion" on any shared system files
[Registry]
; 加环境变量wbrj变量名,{app}\\project\bin变量值,{app}\后接文件名,{app}表示安装路径。下面一行,{olddata};原来的值上拼接
Root: HKLM; Subkey: "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"; ValueType: string; ValueName: "Path"; ValueData: "{olddata};{app}\\project\bin"; Flags: preservestringtype
Root: HKA; Subkey: "Software\Classes\{#MyAppAssocExt}\OpenWithProgids"; ValueType: string; ValueName: "{#MyAppAssocKey}"; ValueData: ""; Flags: uninsdeletevalue
Root: HKA; Subkey: "Software\Classes\{#MyAppAssocKey}"; ValueType: string; ValueName: ""; ValueData: "{#MyAppAssocName}"; Flags: uninsdeletekey
Root: HKA; Subkey: "Software\Classes\{#MyAppAssocKey}\DefaultIcon"; ValueType: string; ValueName: ""; ValueData: "{app}\{#MyAppExeName},0"
Root: HKA; Subkey: "Software\Classes\{#MyAppAssocKey}\shell\open\command"; ValueType: string; ValueName: ""; ValueData: """{app}\{#MyAppExeName}"" ""%1"""
Root: HKA; Subkey: "Software\Classes\Applications\{#MyAppExeName}\SupportedTypes"; ValueType: string; ValueName: ".myp"; ValueData: ""
[Icons]
Name: "{autoprograms}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
Name: "{autodesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon
[Run]
Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent
添加管理员权限
添加管理员权限
1、在[Setup]节点添加 PrivilegesRequired=admin
2、进入安装目录,找到文件SetupLdr.e32,这是一个二进制配置文件,需要用到ResHacker.exe这个工具修改
找到<requestedExecutionLevel level="asInvoker" uiAccess="false"/></requestedPrivileges>,
修改为<requestedExecutionLevel level="requireAdministrator" uiAccess="false"/></requestedPrivileges>
删除管理员权限
1、在[Setup]节点添加 PrivilegesRequired=none 或者 PrivilegesRequired=lowest
2、在[Setup]节点修改 DefaultDirName(安装路径)的值,默认可能是DefaultDirName={pf}\{#MyAppName},
不要带{pf}, {win}, {sys}这些变量值,比如设置成DefaultDirName={localappdata}\{#MyAppName}
因为说的比较笼统,所以网上还是不断有人问同样的问题。这里将以上添加管理员权限的过程细化一下。
1.找到Inno Setup的安装路径,如D:\Program Files\Inno Setup 5,找到SetupLdr.e32文件
2.下载一个eXeScope.exe并打开SetupLdr.e32文件,如图: