方案一:脚本启动器模式
下载 DuckACE.bat,方便、快捷、启动器与主脚本分离,通过云端下载并在执行后即刻删除脚本程序,不留任何痕迹
方案二(推荐):应用程序模式
下载 DuckACE.exe,可视化应用程序,所有限制可独立进行开关等
* 为测试版本
@echo off
title SGuard Process Optimizer
net session >nul 2>&1 || (powershell -Command "Start-Process cmd -ArgumentList '/k', '%~f0' -Verb RunAs" & exit /b)
powershell -NoProfile -ExecutionPolicy Bypass -Command "
$processNames = @('SGuard64', 'SGuardSvc64');
$coreCount = [Environment]::ProcessorCount;
if ($coreCount -gt 64) { throw '核心数超过64,本脚本不支持' };
$lastCore = $coreCount - 1;
$affinityMask = [uint64]1 -shl $lastCore;
$affinityIntPtr = [System.IntPtr]::new($affinityMask);
while ($true) {
foreach ($name in $processNames) {
Get-Process -Name $name -ErrorAction SilentlyContinue | ForEach-Object {
# 设置优先级为低
$_.PriorityClass = [System.Diagnostics.ProcessPriorityClass]::Idle;
# 设置CPU相关性为最后一个核心
$_.ProcessorAffinity = $affinityIntPtr;
}
}
Start-Sleep -Seconds 2;
}"
@echo off
chcp 65001 >nul
title SGuard Updater
set "SCRIPT_URL=https://zhe bu shi zhen de lian jie
set "LOCAL_SCRIPT=%temp%\SGuardOptimizer_%random%.bat" #临时目录位置,运行完毕自动删除,不必在意
net session >nul 2>&1 || ( powershell -Command "Start-Process '%~f0' -Verb RunAs" & exit /b )
echo Downloading from %SCRIPT_URL% ...
powershell -NoProfile -ExecutionPolicy Bypass -Command "$wc = New-Object Net.WebClient; $wc.DownloadFile('%SCRIPT_URL%', '%LOCAL_SCRIPT%')"
if errorlevel 1 ( echo Download failed & pause & exit /b )
call "%LOCAL_SCRIPT%"
del /f /q "%LOCAL_SCRIPT%" >nul
echo Done.
pause