积分 98 最后登录 2024-5-2 精华 0 阅读权限 20 主题 56 UID 890846 帖子 244 PB币 570 威望 0 贡献 0 技术 10 活跃 838
UID 890846 帖子 244 PB币 570 贡献 0 技术 10 活跃 838
本帖最后由 cjrcl 于 2016-11-15 16:00 编辑
经过改进现在脚本对 Acceleration.Level 的修改一个不漏,而且支持多显卡(脚本中的 $Guid 不同)、多显示器(脚本中的 $ObjectNumber 不同)。
------------------------------------------------------------------------------------------------------------------------------------------------------------
先是 Acceleration.Level.bat 用以调用 PowerShell 脚本:
%windir%\System32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy Unrestricted -File Acceleration.Level.ps1 复制代码 ------------------------------------------------------------------------------------------------------------------------------------------------------------
然后是 PowerShell 脚本 Acceleration.Level.ps1:
function WriteKey($File, $Key)
{
ECHO $Key >> $File;
ECHO '"Acceleration.Level"=dword:00000000' >> $File;
ECHO "" >> $File;
}
function Generate($File, $ControlSet)
{
$Item = Get-Item -Path "HKLM:\HARDWARE\DEVICEMAP\VIDEO";
$ValueNames = $Item.GetValueNames();
foreach($ValueName in $ValueNames)
{
if($ValueName.StartsWith("\Device\Video"))
{
$Value = $Item.GetValue($ValueName);
if($Value.Length -gt 43)
{
$Guid = $Value.SubString($Value.Length - 43, 38);
$ObjectNumber = $Value.SubString($Value.Length - 4);
try
{
[System.Guid]::Parse($Guid);
[System.Int32]::Parse($ObjectNumber);
}
catch
{
continue;
}
$Path = "HKLM:\SYSTEM\" + $ControlSet + "\Control\Video\" + $Guid + "\Video";
$Service = (Get-Item -Path $Path).GetValue("Service");
$Path = "HKLM:\SYSTEM\" + $ControlSet + "\Services\" + $Service;
$ChildItems = Get-ChildItem -Path $Path;
foreach($ChildItem in $ChildItems)
{
if($ChildItem.PSChildName.StartsWith("Device"))
{
$Key = "[" + $ChildItem.Name + "]";
WriteKey $File $Key;
}
}
$Key = "[HKEY_LOCAL_MACHINE\SYSTEM\" + $ControlSet + "\Control\Video\" + $Guid + "\" + $ObjectNumber + "]";
WriteKey $File $Key;
$Key = "[HKEY_LOCAL_MACHINE\SYSTEM\" + $ControlSet + "\Control\Video\" + $Guid + "\" + $ObjectNumber + "\Settings]";
WriteKey $File $Key;
}
}
}
$VideoControllers = Get-WmiObject -Class Win32_VideoController;
foreach($VideoController in $VideoControllers)
{
$PnPEntities = Get-WmiObject -Class Win32_PnPEntity;
foreach($PnPEntity in $PnPEntities)
{
if($PnPEntity.PNPDeviceID -eq $VideoController.PNPDeviceID)
{
$Path = "HKLM:\SYSTEM\" + $ControlSet + "\Control\Class\" + $PnPEntity.ClassGuid;
$ChildItems = Get-ChildItem -Path $Path;
foreach($ChildItem in $ChildItems)
{
try
{
[System.Int32]::Parse($ChildItem.PSChildName);
}
catch
{
continue;
}
$Key = "[" + $ChildItem.Name + "]";
WriteKey $File $Key;
$Key = "[" + $ChildItem.Name + "\Settings]";
WriteKey $File $Key;
}
}
}
}
}
$File = "Acceleration.Level.reg";
New-Item $File -Type File -Force;
ECHO "Windows Registry Editor Version 5.00" > $File;
ECHO "" >> $File;
Generate $File "ControlSet001";
Generate $File "ControlSet002";
Generate $File "CurrentControlSet";
TYPE $File;
regedit.exe /s $File; 复制代码 此脚本的作用是生成一个 .reg 文件,再用 regedit.exe 将其导入注册表。关键是找到显卡的 Guid 和 ClassGuid 以及显示驱动 Service 名称,因为它会出现在要导入的 .reg 文件中,对于不同的显卡这个 .reg 文件是不一样的。例如我的显卡的 Guid 是{A444F3DB-5CF8-4395-B9AC-C58D2444C382},ClassGuid 是{4d36e968-e325-11ce-bfc1-08002be10318},显示驱动 Service 名称是 amdkmdap,因此 .reg 文件是下面这样的,由于我的电脑是双显示器配置其中有一些冗余(脚本检查到一个显示器就把它对应的驱动服务改一次,双显示器接同一个显卡那么驱动服务前后就被改了两次):
这个 .reg 文件生成于当前目录,脚本运行结束也不会删除,留给您做参考。貌似大家的 ClassGuid 都是{4d36e968-e325-11ce-bfc1-08002be10318},但是脚本还是动态生成这个 ClassGuid,并没有写死。另外其实对[HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Class\]、[HKEY_LOCAL_MACHINE\SYSTEM\ControlSet002\Control\Class\]、[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\]下的值做修改会导致[HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Video\]、[HKEY_LOCAL_MACHINE\SYSTEM\ControlSet002\Control\Video\]、[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Video\]下的值跟着发生同样的变化。这很好理解,对显卡(class 下的{4d36e968-e325-11ce-bfc1-08002be10318}下的 0000 就是 0 号显卡,0001 就是 1 号显卡)总的做了修改,接在显卡上的显示器(video 下的某个 guid 下的 0000 表示接在与这个 guid 对应的显卡上的 0 号显示器而 0001 就是 1 号显示器)当然会跟着改变。然而脚本为了保险起见对这两处都做修改。
------------------------------------------------------------------------------------------------------------------------------------------------------------
使用方法是把 .bat 跟 .ps1 两个文件放在同一路径下,然后在具有管理员权限的 cmd 窗口 cd 到上述路径,最后运行 .bat 文件。如果就是以 Administrator 登陆的直接双击 .bat 即可。非 Administrator 用户右击选择“以管理员身份运行”是不行的,需要修改一下 .bat 文件才可以,具体见我以前的帖子: https://bbs.pcbeta.com/viewthread-1650074-1-1.html ,那个帖子说的是用 PowerShell 脚本修复(重装)本机所有 Metro App。
=================================================================================================
最后是组策略进行一些调整,也是用 .reg 文件实现(注册表键中都有 Policies 字样,与在 gpedit.msc 中操作效果是相同的):
------------------------------------------------------------------------------------------------------------------------------------------------------------
禁止数据收集:
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\DataCollection]
"AllowTelemetry"=dword:00000000
------------------------------------------------------------------------------------------------------------------------------------------------------------
关闭 Windows Defender:
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows Defender]
"DisableAntiSpyware"=dword:00000001
------------------------------------------------------------------------------------------------------------------------------------------------------------
无需按 Ctrl + Alt + Del 即可登陆:
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System]
"DisableCAD"=dword:00000001
------------------------------------------------------------------------------------------------------------------------------------------------------------
登陆后不自动打开服务器管理器:
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\Server\ServerManager]
"DoNotOpenAtLogon"=dword:00000001
------------------------------------------------------------------------------------------------------------------------------------------------------------
关闭 Windows Update:
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU]
"NoAutoUpdate"=dword:00000001
------------------------------------------------------------------------------------------------------------------------------------------------------------
关闭驱动自动更新:
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\DriverSearching]
"SearchOrderConfig"=dword:00000000
------------------------------------------------------------------------------------------------------------------------------------------------------------
关机或重启无需提供理由:
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows NT\Reliability]
"ShutdownReasonOn"=dword:00000000
------------------------------------------------------------------------------------------------------------------------------------------------------------
于未登陆状态在登陆介面可关机:
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System]
"ShutdownWithoutLogon"=dword:00000001
------------------------------------------------------------------------------------------------------------------------------------------------------------
展开阅读全文​
2
查看全部评分