Delphi 10.4.2:为什么控制台应用程序需要管理特权?
为什么简单的控制台应用需要管理特权?
program LTUpdate;
{$APPTYPE CONSOLE}
begin
WriteLn('Hello World');
end.
- 如果我从命令提示符运行此程序,则什么都不会发生。
- 如果我运行具有管理权的命令提示符,然后输出此程序:
你好世界
在项目中是否有一个复选框,该复选框设置了该应用程序需要管理权?
(最终程序将连接到数据库,获取一些字段并在其他地方进行更新,现在我可以通过VCL进行此操作...但是我认为这次我会尝试一个简单的控制台应用程序。)
Why does a simple console app require administrative privileges?
program LTUpdate;
{$APPTYPE CONSOLE}
begin
WriteLn('Hello World');
end.
- If I run this program from a command prompt nothing happens.
- If I run the command prompt with administrative rights and then this program it outputs:
Hello World
Is there somewhere a checkbox in the project which sets the app to require administrative rights?
(The final program will connect to a database, get some fields and update it elsewhere, now I could do it via VCL... but I thought I'd try a simple console app this time.)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的应用程序被编译为32位,并且缺少包含
请求的ExecutionLevel
值的UAC清单,因此UAC的“安装程序检测器”功能启动,这就是您的应用需要高程的原因:https://learn.microsoft。 com/en-us/windows/security/Identity-protection/user-account-control/how-user-account-control-works
解决此问题的最简单方法是在您的应用程序中添加UAC清单以指定执行级别:
否则,您必须将应用程序重新编译为64位,或更改其名称和版本资源以避免指定的关键字。
Your app is being compiled as 32bit, and lacks a UAC manifest containing a
requestedExecutionLevel
value, so UAC's "Installer Detection" feature kicks in, which is why your app requires elevation:https://learn.microsoft.com/en-us/windows/security/identity-protection/user-account-control/how-user-account-control-works
The simplest way to fix this is to add a UAC manifest to your app to specify an execution level:
Otherwise, you would have to either recompile your app as 64bit, or change its name and version resource to avoid the designated keywords.