"__COMPAT_LAYER"实际上是做什么的? [英] What does '__COMPAT_LAYER' actually do?

查看:975
本文介绍了"__COMPAT_LAYER"实际上是做什么的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近,我试图授予我的应用程序管理员权限,而没有系统询问是否要授予管理员权限?" ,我发现了一种运行良好的方法.

Recently, i was trying to give my application administrator rights without system asking for "Do you want to give administrator rights?" and i found a way which is working perfectly.

我找到的解决方案

我创建了一个名为 nonadmin.bat 的bat文件,并在其中写入了以下代码

I created a bat file named nonadmin.bat and wrote the below code in it

cmd min C set __COMPAT_LAYER=RunAsInvoker && start  %1

如果我们在其上拖动任何exe,它就会向他们授予管理员权限(在没有我允许它访问环境变量之前,而是将文件拖动到bat上,它确实起作用了).

and if we drag any exe on it, it gives them administrator rights (before it was not letting me access environment variables without it but after draging the file on bat it did work).

问题

现在我的问题是:-

  1. "__ COMPAT_LAYER"的实际含义是什么?
  2. 如何删除此类内容,使其再次要求管理员权限?
  3. 这会降低系统安全性吗?

推荐答案

__ COMPAT_LAYER,以及如何使用
__COMPAT_LAYER是一个系统环境变量,它允许您设置兼容性层,即右键单击可执行文件,选择属性"并转到兼容性"选项卡时可以调整的设置.

__COMPAT_LAYER, and How To Use It
__COMPAT_LAYER is a system environment variable that allows you to set compatibility layers, which are the settings you can adjust when you right-click on an executable, select Properties, and go to the Compatibility tab.

除了您知道的一个以外,还有几个选项可供选择关于:

There are several options to choose from in addition to the one you know about:

  • 256色-以256色运行
  • 640x480 -以640x480屏幕分辨率运行
  • DisableThemes -禁用视觉主题
  • Win95 -在Windows 95的兼容模式下运行程序
  • Win98 -在Windows 98/ME的兼容模式下运行程序
  • Win2000 -在Windows 2000的兼容模式下运行程序
  • NT4SP5 -在兼容模式下运行Windows NT 4.0 SP5的程序
  • 256Color - Runs in 256 colors
  • 640x480 - Runs in 640x480 screen resolution
  • DisableThemes - Disables Visual Themes
  • Win95 - Runs the program in compatibility mode for Windows 95
  • Win98 - Runs the program in compatibility mode for Windows 98/ME
  • Win2000 - Runs the program in compatibility mode for Windows 2000
  • NT4SP5 - Runs the program in compatibility mode for Windows NT 4.0 SP5

您可以使用多个选项,只需用空格将它们分开:set __COMPAT_LAYER=Win98 640x480

You can use multiple options by separating them with a space: set __COMPAT_LAYER=Win98 640x480

取消设置__COMPAT_LAYER变量
只要变量存在,这些设置就会持续存在.当关闭设置了变量的命令提示符时,或者使用命令set __COMPAT_LAYER=手动取消设置变量时,该变量将停止存在.

Unsetting the __COMPAT_LAYER Variable
These settings persist for as long as the variable exists. The variable stops existing when either the command prompt in which the variable was set is closed, or when the variable is manually unset with the command set __COMPAT_LAYER=.

由于您是通过批处理脚本设置变量的,因此一旦您将可执行文件拖动到该可执行文件并关闭脚本,该变量便会自动取消设置.重要的是要注意,变量设置会保留到您选择的可执行文件所产生的所有子进程中.

Since you are setting the variable via batch script, the variable is automatically unset once the executable you drag onto it completes and the script closes. It is important to note that the variable settings persist to any child processes that are spawned by the executable you select.

使用__COMPAT_LAYER的安全性
如果没有权限,将__COMPAT_LAYER设置为RunAsInvoker 并不会真正为您提供管理员特权.它只是阻止了UAC弹出窗口的出现,然后

The Security of Using __COMPAT_LAYER
Setting __COMPAT_LAYER to RunAsInvoker does not actually give you administrator privileges if you do not have them; it simply prevents the UAC pop-up from appearing and then runs the program as whatever user called it. As such, it is safe to use this since you are not magically obtaining admin rights.

您还可以将变量设置为 RunAsHighest (仅当您具有管理员权限时才触发UAC权限,但如果您没有管理员权限也不会授予管理员权限)或RunAsAdmin(始终会触发UAC).

You can also set the variable to RunAsHighest (only triggers UAC if you have admin rights, but also does not grant admin rights if you do not have them) or RunAsAdmin (always triggers UAC).

这篇关于"__COMPAT_LAYER"实际上是做什么的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆