本文介绍了Inno Setup安装-访问被拒绝的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用inno setup创建了一个安装.我的应用程序(除其他外)运行后在子文件夹内创建一个pdf文件,然后将其打开.但是Windows 7表示访问被拒绝,并弹出异常.怎么了?如何使用innosetup授予对子文件夹的访问权限?这是ino中的代码片段:

I have created an installation with inno setup. My app (among other things) after is run creates a pdf file inside a subfolder and then opens it. But windows 7 says access denied and exception pops up. What's wrong? How to grant access to subfolders using innosetup?Here's the code snippet inside ino:

Source: "C:\Users\Someone\Desktop\NET\Animations\*"; DestDir: "{app}\Animations"; Flags: ignoreversion recursesubdirs createallsubdirs

推荐答案

大概是因为您正试图从不同用户的私人文件夹中复制文件.那是禁止进入的.您只能将文件放入当前用户的文件夹(运行安装的文件夹)中.无论如何,很难想象有理由为什么要这样做.

Presumably because you're trying to copy the file from a different user's private folder. That's off-limits. You can only place files into the current user's folder (the one who is running the install). It's difficult to imagine a good reason why you'd want to do otherwise, anyway.

尝试使用 {userdocs} 常量.使用 ExpandConstant 将其扩展到完整路径.

Try using the {userdocs} constant, instead. Use ExpandConstant to expand it to the full path.

如果您需要将东西放在所有用户可以访问的位置,则需要以管理"权限运行安装程序.然后,您将能够从 All Users 配置文件目录中进行读取/写入.

If you need things to go in a location that will be accessible to all users, you need to run the installer with Administrative privileges. Then, you'll be able to read/write from the All Users profile directory.

编辑:抱歉.我完全错过了您的问题部分,即您说要在安装 之后执行此操作.我只是看了一下代码,以为这是Inno Setup在安装过程中 所做的事情.

Ah, sorry. I totally missed the part of your question where you said you were trying to do this after installation. I just looked at the code and thought this was something you were having Inno Setup do during the setup process.

对于安装完成后的 ,这是完全不同的答案.Windows 7(由于 UAC )不允许您的应用(或任何应用程序)写入系统文件夹.其中包括 Windows 目录, Program Files 文件夹及其包含的任何文件夹.这是一项安全措施,旨在阻止应用程序在不属于它们的地方运行.

It's a completely different answer for something after the installation has completed. Windows 7 (thanks to UAC) doesn't let your app (or any app, for that matter) write to system folders. That includes the Windows directory, as well as the Program Files folder and any of the folders it contains. This is a security measure, intended to stop applications from running amok in places where they don't belong.

您有两种不同的选择:

  1. 如果您绝对需要对 Program Files 文件夹的写权限,则可以提示用户提升应用程序的流程.基本上,这意味着您将请求管理特权,并且他们将看到UAC的一个框,要求他们提供密码.

  1. If you absolutely need write access to the Program Files folder, you can prompt the user to elevate your application's process. Basically, that means that you'll be requesting Administrative privileges, and they'll see a box from UAC asking them for a password.

我在.对于以其他任何语言编写的应用程序,您将遵循类似的步骤;您只是在调用Windows API中内置的函数.

I give more information about how you might go about doing that from a C# application in my answer to this question. You'll follow similar steps for an app written in any other language; you're just calling functions built into the Windows API.

更好的 选项是修改您的应用程序,以便它不需要写入系统文件夹.这样,您将不必具有管理特权即可运行.这是所有标准Windows应用程序的预期模型.微软至少从Windows 2000的早期就一直推荐它,但是直到Vista为止,您实际上并没有被迫遵循它.

The better option, though, is to modify your application so that it doesn't have to write to system folders. That way, you won't have to run with Administrative privileges. This is the intended model for all standard Windows applications. Microsoft has been recommending it at least since the early days of Windows 2000, but you weren't actually forced into following it until Vista.

我在.

这篇关于Inno Setup安装-访问被拒绝的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-29 15:26
查看更多