windows “__COMPAT_LAYER”实际上是做什么的?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/37878185/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What does '__COMPAT_LAYER' actually do?
提问by Agent_Spock
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.
最近,我试图授予我的应用程序管理员权限,而没有系统询问“您要授予管理员权限吗?” 我找到了一种完美运行的方法。
Solution I Found
我找到的解决方案
I created a bat file named nonadmin.batand wrote the below code in it
我创建了一个名为nonadmin.bat的 bat 文件并在其中编写了以下代码
cmd min C set __COMPAT_LAYER=RunAsInvoker && start %1
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).
如果我们将任何 exe 拖到它上面,它就会给他们管理员权限(在它没有让我访问没有它的环境变量之前,但是在将文件拖到 bat 之后它确实起作用了)。
Question
题
Now my question is:-
现在我的问题是:-
- What actually '__COMPAT_LAYER' means and what does it do?
- How do i remove such a thing so that it asks for administrator rights again?
- Does this reduce system security?
- “__COMPAT_LAYER”实际上是什么意思,它有什么作用?
- 我如何删除这样的东西,以便它再次要求管理员权限?
- 这会降低系统安全性吗?
回答by SomethingDark
__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.
__COMPAT_LAYER 和如何使用它
__COMPAT_LAYER 是一个系统环境变量,它允许您设置兼容性层,这是您可以在右键单击可执行文件、选择属性并转到兼容性选项卡时调整的设置。
There are several options to choose fromin addition to the one you know about:
- 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
- 256Color- 以 256 色运行
- 640x480- 以 640x480 的屏幕分辨率运行
- DisableThemes- 禁用视觉主题
- Win95- 在 Windows 95 兼容模式下运行程序
- Win98- 在 Windows 98/ME 的兼容模式下运行程序
- Win2000- 在 Windows 2000 兼容模式下运行程序
- NT4SP5- 在 Windows NT 4.0 SP5 的兼容模式下运行程序
You can use multiple options by separating them with a space: set __COMPAT_LAYER=Win98 640x480
您可以使用空格分隔多个选项: set __COMPAT_LAYER=Win98 640x480
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=
.
取消
设置__COMPAT_LAYER 变量只要变量存在,这些设置就会一直存在。当设置变量的命令提示符关闭或使用命令手动取消设置变量时,变量将停止存在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.
由于您是通过批处理脚本设置变量,一旦您拖到其上的可执行文件完成并且脚本关闭,变量就会自动取消设置。请务必注意,变量设置会持续存在于您选择的可执行文件生成的任何子进程中。
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.
使用 __COMPAT_LAYER 的安全性如果您没有管理员权限,将 __COMPAT_LAYER
设置为 RunAsInvoker实际上并不会授予您管理员权限。它只是防止出现 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).
您还可以将变量设置为RunAsHighest(只有在您拥有管理员权限时才触发 UAC,如果您没有管理员权限,则不会授予管理员权限)或 RunAsAdmin(始终触发 UAC)。