我通过InnoIDE中的向导创建了一个非常简单的inno脚本。但是,部署的可执行文件可以由普通用户运行。如何强制用户必须通过脚本以管理员身份运行它?
[Setup]
AppId={{03E6645E-2C53-4E90-967B-D0833A8EBDAF}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={pf}\{#MyAppName}
DefaultGroupName={#MyAppName}
OutputBaseFilename=setup
Compression=lzma
SolidCompression=yes
PrivilegesRequired=admin
[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"
[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: " {cm:AdditionalIcons}"; Flags: unchecked
[Files]
Source: "C:\Program Files\Inno Setup 5\Examples\MyProg.exe"; DestDir: {app}; Flags: ignoreversion; Permissions: admins-readexec;
; NOTE: Don't use "Flags: ignoreversion" on any shared system files
[Icons]
Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
Name: "{commondesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon
[Run]
Filename: {app}\{#MyAppExeName}; Description: "{cm:LaunchProgram, {#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent;
答案 0 :(得分:3)
您无法使用Inno更改应用程序的权限或清单。
要使您的应用程序要求管理员权限,您需要为其添加适当的清单。对于每种不同的编程语言,这都是不同的,但many related questions已经被询问和回答。
答案 1 :(得分:0)
更简单的方法让您的应用程序要求管理员权限:
在您的可执行文件的注册表项中添加此值:
[Registry]
Root: "HKLM"; Subkey: "SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers"; ValueType: string; ValueName: "{app}\{#MyAppExeName}"; ValueData: "RUNASADMIN"; Flags: uninsdeletevalue
我更喜欢使用上面的代码。