C: Windows 7 中的驱动器访问权限
在 matlab 中,我使用了 Windows 独立应用程序。此应用程序中有一行在 C:\...\...\
中写入文件。当我运行从此 Windows 独立应用程序生成的输出 exe 文件时,该 exe 不会写入 C:\...\...\
也不会告诉我其中存在安全问题分割。执行所做的一切都是无意义的。但是,当我右键单击并以管理员身份运行该exe时,它运行正常。
我想在不右键单击并以管理员身份运行的情况下执行此操作。 matlab中有没有命令可以做到这一点?
In matlab, I used a windows standalone application. There is a line in this application that writes a file in C:\...\...\
. When I run the output exe file produced from this windows standalone application, the exe doesn't write in C:\...\...\
neither tells me that there is a security issues in that partition. All the execution does is nothing. But, when I right-click and run the exe as administrator, it runs correctly.
I want to do it without right-click and run as administrator. Are there is a command in matlab that can do that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
如果您创建应用程序的快捷方式,则可以转到快捷方式的“属性”,单击“快捷方式”选项卡中的“高级”,然后选择“以管理员身份运行”。这样,每当您从快捷方式启动应用程序时,它都会以管理员身份运行。
(免责声明:应用程序确实不应该通过写入程序文件来“弄脏自己的巢”。这是糟糕的设计。)
If you create a shortcut to your application, you can go to the Properties of the shortcut, click on Advanced in the Shortcut tab, and select "Run as administrator". That way, whenever you start the application from the shortcut it will be run as an administrator.
(Disclaimer: applications really shouldn't "foul their own nest" by writing into Program Files. This is bad design.)
从 Vista 开始,非特权进程不允许写入受保护的文件夹(例如 Program Files),因为 Program Files 旨在存储代码而不是数据。然而,由于 XP 中并未强制执行此限制,因此 MS 以虚拟存储的形式提供了向后兼容性 hack。现在,当程序尝试写入受保护的文件夹时,其输出将被重定向到专用文件夹中。这样,程序仍然“认为”它写入到其通常的位置,而实际上它写入到不受保护的位置。但是,当您稍后检查程序文件位置时,您可能看不到该文件 - 因为它并不真正在那里。
您可以在此处找到更多详细信息: 用户帐户控制数据重定向。
Starting from Vista, unprivileged processes are not allowed to write to protected folders such as Program Files, because Program Files is designed to store code and not data. However, since this limitation has not been enforced in XP, MS has provided a backward-compatibility hack in the form of Virtual Store. Now, when a program tries to write to protected folder, its output is being redirected into a dedicated folder. This way, the program still "thinks" it writes to its usual location, while in fact it writes to an unprotected location. However, when you later check the Program Files location, you might not see the file - because it's not really there.
You can find more details here: User Account Control Data Redirection.
如果您是管理员,请为您的用户名添加对目标文件夹的完全控制权限。您可以通过右键单击该文件夹,转到属性,然后转到安全选项卡来执行此操作。然后编辑并添加具有
完全控制
权限的用户名。然后您不必以管理员身份运行该程序。If you are administrator, add full control permission for your username to the destination folder. You do that by right clicking on the folder, going to properties and then security tab. Then edit and add you username with
Full Control
rights. Then you don;t have to run the the program as an administrator.一旦进程启动,您就无法提升进程的权限,因此 Matlab 不可能有相应的命令。只是运行Matlab 提升。
There is no way you can elevate a process once it is started, so Matlab cannot possibly have a command for that. Just running Matlab elevated.