inno-setup - Inno 更新脚本,访问被拒绝...代码 5
问题描述
这不是我之前问过的同一个问题......我在问为什么在构建到 {commonappdata} 文件夹时出现代码 5 错误。
我有两个 inno 脚本,设置一个为所有用户安装一个应用程序,并将其安装为启动应用程序,因此我们需要管理员权限。我将它设置为安装到 {commonappdata} (ProgramData),以便它成为所有用户的程序。这工作正常。
这是安装脚本:(似乎没有问题)
; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
#define MyAppName "xxxx"
#define MyAppVersion "xxxx"
#define MyAppPublisher "xxxxxxx"
#define MyAppURL "http://www.example.com/"
#define MyAppExeName "xxxxxx.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.)
AppId={{xxxxxxxxxxxxxxxxxx}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={commonappdata}\{#MyAppName}
DisableDirPage=yes
DefaultGroupName={#MyAppName}
AllowNoIcons=yes
; The [Icons] "quicklaunchicon" entry uses {userappdata} but its [Tasks] entry has a proper IsAdminInstallMode Check.
UsedUserAreasWarning=no
; Remove the following line to run in administrative install mode (install for all users.)
PrivilegesRequired=admin
OutputBaseFilename=xxxxxx
Compression=lzma
SolidCompression=yes
WizardStyle=modern
[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"
[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
Name: "quicklaunchicon"; Description: "{cm:CreateQuickLaunchIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked; OnlyBelowVersion: 6.1; Check: not IsAdminInstallMode
[Files]
Source: "C:\xxx\xxxx\Desktop\xxxxxx\xxxxx.exe"; DestDir: "{app}";
Source: "C:\xxx\xxxx\Desktop\xxxxx\*"; DestDir: "{app}"; Flags: recursesubdirs createallsubdirs
; NOTE: Don't use "Flags: ignoreversion" on any shared system files
[Registry]
Root: HKLM; Subkey: "SOFTWARE\Microsoft\Windows\CurrentVersion\Run"; ValueType: string; ValueName: "{#MyAppName}"; ValueData: """{app}\{#MyAppExeName}"""; Flags: uninsdeletevalue
[Icons]
Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
Name: "{autodesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon
Name: "{userappdata}\Microsoft\Internet Explorer\Quick Launch\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: quicklaunchicon
[Run]
Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent
然后更新脚本稍后由 C# 下载(如果有更新的版本),它的整个想法是它更新 {commonappdata} (programdata) 路径,因此它为机器上的每个用户更新,它确实不需要管理员权限即可。同时仍将其作为启动应用程序进行维护。
更新脚本:
; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
#define MyAppName "xxxx"
#define MyAppVersion "xxxx"
#define MyAppPublisher "xxxxxxxxxx"
#define MyAppURL "http://www.example.com/"
#define MyAppExeName "xxxxxxx.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.)
AppId={{xxxxxxxxxx}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={commonappdata}\{#MyAppName}
DisableDirPage=yes
DefaultGroupName={#MyAppName}
AllowNoIcons=yes
; The [Icons] "quicklaunchicon" entry uses {userappdata} but its [Tasks] entry has a proper IsAdminInstallMode Check.
UsedUserAreasWarning=no
; Remove the following line to run in administrative install mode (install for all users.)
PrivilegesRequired=lowest
OutputBaseFilename=xxxxxx
Compression=lzma
SolidCompression=yes
WizardStyle=modern
[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"
[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
Name: "quicklaunchicon"; Description: "{cm:CreateQuickLaunchIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked; OnlyBelowVersion: 6.1; Check: not IsAdminInstallMode
[Files]
Source: "C:\xxxx\xxxxx\Desktop\xxxxxxx\xxxxxxxx.exe"; DestDir: "{app}"; Flags: ignoreversion
Source: "C:\xxxxx\xxxx\Desktop\xxxxxxxx\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
; NOTE: Don't use "Flags: ignoreversion" on any shared system files
[Icons]
Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
Name: "{autodesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon
Name: "{userappdata}\Microsoft\Internet Explorer\Quick Launch\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: quicklaunchicon
[Run]
Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent
我的问题是,当更新脚本运行时,它给了我错误代码:“尝试替换现有文件时发生错误:C:\ProgramData\APP NAME\FILE.EXE: DeleteFile failed; code 5. ACCESS IS拒绝。
请帮忙。我的意思是我知道问题是,我想我什至无法访问或更改 ProgramData 文件夹(不安装时),您需要该文件夹中的管理员权限。但我不知道还有什么地方可以在不需要管理员权限的情况下完成更新(对于每个用户)。
解决方案
您需要管理员权限才能写入该commonappdata
文件夹。请参阅此处提到的地方:
你让自己很难受。按照设计,您的安装程序要么被提升要么没有。
- 如果必须使用任何
common
常量,则需要管理员权限。 - 如果您使用任何
auto
带有海拔的常量,它只会为用户安装。
推荐阅读
- php - 数组的排列,但已知一些值
- javascript - 在Javascript中获取键的属性
- javascript - 需要检查 Javascript 中的特定按键
- android - 如何从资源中使用 int 数组中的可绘制对象
- c# - 选择要删除的文件。要删除,请键入文件否
文件号 示例 3 1 - html - 使用表格布局允许元素在表格中溢出:已修复
- reactjs - 在 JSX | React 如何将 prop 传递给按钮状态,以便按钮状态可以加载新页面?
- javascript - Firebase 通过 Promises 返回的多个异步请求
- bash - VS Code 终端高亮提示
- java - 与时间窗口聚合的 Kafka KStreams 问题