如何在Windows 8.1中使M​​icrosoftpipe理控制台识别出高DPI?

由于Windows 8.1不支持全系统的“Windows XP风格”高DPI支持,我怎样才能让Microsoftpipe理控制台应用程序(mmc.exe)知道高DPI? 它没有“疑难解答兼容性”上下文菜单项。

“兼容性”选项卡对于系统文件是隐藏的,因此要复制“在高DPI设置上禁用显示比例”checkbox,您可以将以下内容添加到registry中:

Windows Registry Editor Version 5.00 [HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers] "C:\\Windows\\System32\\mmc.exe"="~ HIGHDPIAWARE" 

这还有一个好处,就是像组策略编辑器一样使用所有的MMCpipe理单元也可以使用本地扩展而不是模糊的光栅化版本。

您可以将其保存为.reg文件并将其导入,或者将以下命令粘贴到“运行”对话框中:

reg add "HKCU\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers" /v "C:\Windows\System32\mmc.exe" /f /t REG_SZ /d "~ HIGHDPIAWARE"

如果您经常使用该解决方法,则可能需要将其添加到.exe文件的右键单击上下文菜单中。 您还可以将其添加到.msi文件,因为兼容性选项卡也缺less这些文件:

 Windows Registry Editor Version 5.00 [-HKEY_CLASSES_ROOT\exefile\shell\disabledpi] [HKEY_CLASSES_ROOT\exefile\shell\disabledpi] @="Disable DP&I Scaling" [HKEY_CLASSES_ROOT\exefile\shell\disabledpi\command] @="cmd /c @reg add \"HKCU\\Software\\Microsoft\\Windows NT\\CurrentVersion\\AppCompatFlags\\Layers\" /v \"%1\" /f /t REG_SZ /d \"~ HIGHDPIAWARE\">nul" "IsolatedCommand"="cmd /c @reg add \"HKCU\\Software\\Microsoft\\Windows NT\\CurrentVersion\\AppCompatFlags\\Layers\" /v \"%1\" /f /t REG_SZ /d \"~ HIGHDPIAWARE\">nul" [-HKEY_CLASSES_ROOT\Msi.Package\shell\disabledpi] [HKEY_CLASSES_ROOT\Msi.Package\shell\disabledpi] @="Disable DP&I Scaling" [HKEY_CLASSES_ROOT\Msi.Package\shell\disabledpi\command] @="cmd /c @reg add \"HKCU\\Software\\Microsoft\\Windows NT\\CurrentVersion\\AppCompatFlags\\Layers\" /v \"%1\" /f /t REG_SZ /d \"~ HIGHDPIAWARE\">nul" "IsolatedCommand"="cmd /c @reg add \"HKCU\\Software\\Microsoft\\Windows NT\\CurrentVersion\\AppCompatFlags\\Layers\" /v \"%1\" /f /t REG_SZ /d \"~ HIGHDPIAWARE\">nul" 

由于“以pipe理员身份运行”和“禁用DPI缩放”设置存储在一起,因此在已设置为以admin身份运行的文件上调用该命令将清除该标志并设置DPI缩放标志。 这只会影响您手动选中该框的文件,而不会影响清单中具有正确的requestedExecutionLevel的文件。

仅供参考,当两者都检查string是“〜RUNASADMIN HIGHDPIAWARE”,但我不会把它放到上下文菜单选项,因为它已经可以在上下文菜单上一次性使用,这不是一个好主意,使pipe理员令牌很容易。

如果您想要禁用特定文件夹中可执行文件和安装程序文件的DPI缩放,则可以使用以下.reg导入:

 Windows Registry Editor Version 5.00 [-HKEY_CLASSES_ROOT\Directory\shell\disabledpi] [HKEY_CLASSES_ROOT\Directory\shell\disabledpi] @="Disable DP&I Scaling" [HKEY_CLASSES_ROOT\Directory\shell\disabledpi\command] @="cmd /c @start /min cmd /c for /f \"usebackq delims=\" %%i in (`dir /b /s \"%1\\*.exe\" \"%1\\*.msi\"`) do @reg add \"HKCU\\Software\\Microsoft\\Windows NT\\CurrentVersion\\AppCompatFlags\\Layers\" /v \"%%i\" /f /t REG_SZ /d \"~ HIGHDPIAWARE\"" "IsolatedCommand"="cmd /c @start /min cmd /c for /f \"usebackq delims=\" %%i in (`dir /b /s \"%1\\*.exe\" \"%1\\*.msi\"`) do @reg add \"HKCU\\Software\\Microsoft\\Windows NT\\CurrentVersion\\AppCompatFlags\\Layers\" /v \"%%i\" /f /t REG_SZ /d \"~ HIGHDPIAWARE\"" 

在像Program Files这样的根级文件夹上使用该选项是一个坏主意,因为您将创build数百个registry项。 但是在某些情况下,尤其是对于Process Explorer以及其他Sysinternals实用程序或Nirsoft实用程序而言,所有这些工具在禁用DPI缩放的情况下运行良好,但没有在其清单中明确指定的选项。

最后一批代码使用内部启动命令尽快获取命令提示符窗口,并在parsing文件夹内容时使其保持最小化。 @符号用于防止在输出中回显命令,并且无redirect用于隐藏输出“操作成功完成”。 为每个条目,因为它永远不会改变。

如果您碰巧拥有优秀的nircmd工具,您可以完全隐藏命令提示符窗口的简短提示:

 Windows Registry Editor Version 5.00 [-HKEY_CLASSES_ROOT\exefile\shell\disabledpi] [HKEY_CLASSES_ROOT\exefile\shell\disabledpi] @="Disable DP&I scaling" [HKEY_CLASSES_ROOT\exefile\shell\disabledpi\command] @="nircmd.exe execmd reg add \"HKCU\\Software\\Microsoft\\Windows NT\\CurrentVersion\\AppCompatFlags\\Layers\" /v \"%1\" /f /t REG_SZ /d \"~ HIGHDPIAWARE\"" "IsolatedCommand"="nircmd.exe execmd reg add \"HKCU\\Software\\Microsoft\\Windows NT\\CurrentVersion\\AppCompatFlags\\Layers\" /v \"%1\" /f /t REG_SZ /d \"~ HIGHDPIAWARE\"" [-HKEY_CLASSES_ROOT\Msi.Package\shell\disabledpi] [HKEY_CLASSES_ROOT\Msi.Package\shell\disabledpi] @="Disable DP&I scaling" [HKEY_CLASSES_ROOT\Msi.Package\shell\disabledpi\command] @="nircmd.exe execmd reg add \"HKCU\\Software\\Microsoft\\Windows NT\\CurrentVersion\\AppCompatFlags\\Layers\" /v \"%1\" /f /t REG_SZ /d \"~ HIGHDPIAWARE\"" "IsolatedCommand"="nircmd.exe execmd @reg add \"HKCU\\Software\\Microsoft\\Windows NT\\CurrentVersion\\AppCompatFlags\\Layers\" /v \"%1\" /f /t REG_SZ /d \"~ HIGHDPIAWARE\"" [-HKEY_CLASSES_ROOT\Directory\shell\disabledpi] [HKEY_CLASSES_ROOT\Directory\shell\disabledpi] @="Disable DP&I scaling" [HKEY_CLASSES_ROOT\Directory\shell\disabledpi\command] @="nircmd.exe execmd for /f \"usebackq delims=\" %%i in (`dir /b /s \"%1\\*.exe\" \"%1\\*.msi\"`) do @reg add \"HKCU\\Software\\Microsoft\\Windows NT\\CurrentVersion\\AppCompatFlags\\Layers\" /v \"%%i\" /f /t REG_SZ /d \"~ HIGHDPIAWARE\"" "IsolatedCommand"="nircmd.exe execmd for /f \"usebackq delims=\" %%i in (`dir /b /s \"%1\\*.exe\" \"%1\\*.msi\"`) do @reg add \"HKCU\\Software\\Microsoft\\Windows NT\\CurrentVersion\\AppCompatFlags\\Layers\" /v \"%%i\" /f /t REG_SZ /d \"~ HIGHDPIAWARE\"" 

如果nircmd.exe不在您的path中,您可以添加上面的位置,或者将其文件夹添加到“系统环境variables”对话框中的path中。 要显示这个窗口,你可以使用命令rundll32 sysdm.cpl,EditEnvironmentVariables

通过在运行时创build一个.reg文件来添加registry键值会更优雅,并且可以通过无文档reg import /s选项静默reg import /s 。 但根据我的经验,在运行时编写任何文件都会引发各种安全产品的警报,例如COMODO Internet Securita,来自Panda,Norton等的版本以及基于HIPS模型的任何文件。 当上述工作正常时,我认为没有必要这样做,特别是如果您在多台计算机上使用此function或共享此function,并且不想为其他人创build虚惊。

但是,如果您已经使用nircmd,那么使用regsetval命令而不是regsetval和.msi shell扩展名是有意义的。 该文件夹选项仍然需要遍历目录列表添加每个条目,所以它不会为那些工作。 PowerShell和VBScript是选项,但是它们的可用性取决于Windows的版本和其他一些variables。 从安全的angular度来看,VBScript作为一个漏洞利用向量,尤其是从互联网上下载或者在networking上共享的时候就有了名声,如果没有明确的设置PowerShell的执行策略来允许远程签名的脚本的话,PS1脚本根本就不会运行。

如果在使用该代码时发现有任何exception,请告诉我,因为它仍在进行中。 这就是说,它应该使configurationWindows 8.1的DPI设置更容易。

在Windows 10上,您可以通过执行以下操作获得相同的效果:

1:根据你有哪个版本(find它,打Windows + R,键入“winver”,按Enter键):

  • 构build15019之前:打开控制面板,显示,更改项目大小,设置自定义缩放级别
  • build立15019或更高版本:打开设置,系统,显示,自定义缩放

即使在下拉菜单中可用,也要手动input缩放级别。 如果系统提示您注销设置以使其生效,则会知道您的设置正确无误。

2:将以下内容保存到桌面上的.reg文件中,双击它以将内容添加到registry中:

 Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\SideBySide] "PreferExternalManifest"=dword:00000001 

3:将以下文件保存为c:\windows\system32\mmc.exe.manifest

 <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <!-- Copyright (c) Microsoft Corporation --> <assembly xmlns="urn:schemas-microsoft-com:asm.v1" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3" manifestVersion="1.0"> <assemblyIdentity processorArchitecture="x86" version="5.1.0.0" name="Microsoft.Windows.MMC" type="win32" /> <description>Microsoft Management Console</description> <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3"> <security> <requestedPrivileges> <requestedExecutionLevel level="highestAvailable" uiAccess="false" /> </requestedPrivileges> </security> </trustInfo> <asmv3:application> <asmv3:windowsSettings xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings"> <dpiAware>True/PM</dpiAware> </asmv3:windowsSettings> </asmv3:application> </assembly> 

4:打开任何MMC窗口(服务,设备pipe理器等),他们现在将变得更大,更清晰