直接复制粘贴到管理员右键即可
# --- 1. 权限检查:确保以管理员身份运行 ---
if (-not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) {
Write-Host "请以管理员身份运行此脚本!" -ForegroundColor Red
return
}
Write-Host "正在开始清理 Xbox Game Bar 相关组件..." -ForegroundColor Cyan
# --- 2. 卸载 Xbox 相关组件 ---
Write-Host "[1/3] 正在卸载 Appx 软件包..." -ForegroundColor Yellow
$packages = @(
"Microsoft.XboxGamingOverlay",
"Microsoft.XboxGameOverlay",
"Microsoft.XboxSpeechToTextOverlay"
)
foreach ($pkg in $packages) {
Get-AppxPackage $pkg -AllUsers | Remove-AppxPackage -ErrorAction SilentlyContinue
}
# --- 3. 禁用 GameDVR 注册表配置 ---
Write-Host "[2/3] 正在修改 GameDVR 策略..." -ForegroundColor Yellow
$regConfig = @(
@{ Path = "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\GameDVR"; Name = "AppCaptureEnabled"; Value = 0 },
@{ Path = "HKCU:\System\GameConfigStore"; Name = "GameDVR_Enabled"; Value = 0 }
)
foreach ($item in $regConfig) {
if (-not (Test-Path $item.Path)) { New-Item -Path $item.Path -Force | Out-Null }
Set-ItemProperty -Path $item.Path -Name $item.Name -Value $item.Value -Type DWord -Force
}
# --- 4. 彻底禁用协议关联 (防止弹出“需要新应用以打开此 ms-gamebar 链接”) ---
Write-Host "[3/3] 正在劫持 ms-gamebar 协议关联..." -ForegroundColor Yellow
$protPaths = @("Registry::HKEY_CLASSES_ROOT\ms-gamebar", "Registry::HKEY_CLASSES_ROOT\ms-gamebarservices")
foreach ($path in $protPaths) {
# 创建基础路径
if (-not (Test-Path $path)) { New-Item -Path $path -Force | Out-Null }
# 设置协议头
Set-Item -Path $path -Value "URL:ms-gamebar" -Force
Set-ItemProperty -Path $path -Name "URL Protocol" -Value "" -Force
Set-ItemProperty -Path $path -Name "NoOpenWith" -Value "" -Force
# 劫持 Open 命令,指向空运行程序
$cmdPath = "$path\shell\open\command"
if (-not (Test-Path $cmdPath)) { New-Item -Path $cmdPath -Force | Out-Null }
Set-Item -Path $cmdPath -Value "$env:SystemRoot\System32\systray.exe" -Force
}
Write-Host "-------------------------------------------"
Write-Host "操作完成!Xbox Game Bar 已被深度禁用。" -ForegroundColor Green
Write-Host "提示:建议重启资源管理器 (explorer.exe) 或重启电脑以生效。" -ForegroundColor Gray$env:RUSTUP_DIST_SERVER='https://mirrors4.tuna.tsinghua.edu.cn/rustup'; $env:RUSTUP_UPDATE_ROOT='https://mirrors4.tuna.tsinghua.edu.cn/rustup/rustup'; [Environment]::SetEnvironmentVariable("RUSTUP_DIST_SERVER", "https://mirrors4.tuna.tsinghua.edu.cn/rustup", "User"); [Environment]::SetEnvironmentVariable("RUSTUP_UPDATE_ROOT", "https://mirrors4.tuna.tsinghua.edu.cn/rustup/rustup", "User"); $cargoPath = [System.IO.Path]::Combine($env:USERPROFILE, ".cargo"); if (!(Test-Path $cargoPath)) { New-Item -Path $cargoPath -ItemType Directory }; $configContent = "[source.crates-io]`nreplace-with = 'tuna'`n`n[source.tuna]`nregistry = 'https://mirrors.tuna.tsinghua.edu.cn/git/crates.io-index.git'"; Set-Content -Path (Join-Path $cargoPath "config") -Value $configContent -Encoding UTF8; Write-Host "--- 配置已完成!请重启终端后安装 Rust ---" -ForegroundColor Greenwindows
$filePath = Join-Path $env:APPDATA 'uv\uv.toml'
$dir = Split-Path $filePath -Parent
New-Item -Path $dir -ItemType Directory -Force | Out-Null
@"
python-install-mirror = "https://registry.npmmirror.com/-/binary/python-build-standalone"
[[index]]
url = "https://mirrors.bfsu.edu.cn/pypi/web/simple"
# url = "https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple"
# url = "https://mirrors.cernet.edu.cn/pypi/web/simple"
default = true
"@ | Set-Content -Path $filePathbash
mkdir -p ~/.config/uv && \
cat << EOF >> ~/.config/uv/uv.toml
python-install-mirror = "https://registry.npmmirror.com/-/binary/python-build-standalone"
[[index]]
url = "https://mirrors.bfsu.edu.cn/pypi/web/simple"
# url = "https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple"
# url = "https://mirrors.cernet.edu.cn/pypi/web/simple"
default = true
EOF网络不佳可以windows直接下载uv0.76.exe 蓝奏云 或者 123盘 uv官网
把上面下载的uv.exe放项目根目录,然后运行uv sync
- 下载
OOBC驱动 https://learn.microsoft.com/en-us/sql/connect/odbc/download-odbc-driver-for-sql-server?view=sql-server-ver16 - Sql Server 配置管理器-SQL SERVER 网络配置-SQLEXPRESS的协议-TCP/IP属性-IP地址-IPALL-TCP动态端口留空 TCP端口对应下面的1433-重启sql服务
import pyodbc
import pandas as pd
# 数据库连接配置
conn_str = (
"DRIVER={ODBC Driver 18 for SQL Server};"
"SERVER=localhost\\SQLEXPRESS,1433;"
"DATABASE=BlockchainPolicyDB;"
"Trusted_Connection=yes;"
"TrustServerCertificate=yes;"
)
conn = pyodbc.connect(conn_str)
cursor = conn.cursor()chcp 65001
@echo off
setlocal enabledelayedexpansion
:: 获取批处理文件所在目录(带引号处理)
set "scriptDir=%~dp0"
set "edgeDir=%scriptDir%EdgeData"
set "regPath=HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Edge"
:: 创建目标目录结构
if not exist "%edgeDir%" (
mkdir "%edgeDir%\User Data"
mkdir "%edgeDir%\Cache"
echo 已创建目录结构:%edgeDir%
)
:: 关闭所有Edge进程
taskkill /f /im msedge.exe >nul 2>&1
echo 已终止所有Edge进程...
timeout /t 2 >nul
:: 迁移现有用户数据(首次运行有效)
if exist "%LocalAppData%\Microsoft\Edge\User Data" (
robocopy "%LocalAppData%\Microsoft\Edge\User Data" "%edgeDir%\User Data" /MIR /R:3 /W:5
echo 已迁移历史数据...
)
:: 写入注册表配置
reg add "%regPath%" /v "UserDataDir" /d "%scriptDir%profile" /f >nul
reg add "%regPath%" /v "DiskCacheDir" /d "%edgeDir%\Cache" /f >nul
echo 已更新注册表配置...
pause
## 移动Public\Desktop 所有文件到当前bat目录
```bat
@echo off
setlocal
:: get current bat path
set currentDir=%~dp0
set publicDesktop=%PUBLIC%\Desktop
set movedFiles=0
if exist "%publicDesktop%" (
echo Public Desktop found.
for %%f in ("%publicDesktop%\*") do (
echo Moving %%f
move "%%f" "%currentDir%"
if not errorlevel 1 (
set /a movedFiles+=1
echo Moved: %%f
)
)
if %movedFiles% equ 0 (
echo no file
)
) else (
echo Public Desktop not found.
)
pause
endlocal
另存为bat格式运行即可
taskkill /f /im explorer.exe
attrib -h -i %userprofile%\AppData\Local\IconCache.db
del %userprofile%\AppData\Local\IconCache.db /a
start explorerimport matplotlib.pyplot as plt
plt.rcParams["font.sans-serif"] = ["SimHei"] # 用来正常显示中文标签
plt.rcParams["axes.unicode_minus"] = False # 用来正常显示负号from sklearn.preprocessing import MinMaxScaler
# 归一化
scaler = MinMaxScaler(feature_range=(0, 1))
data_normalized = scaler.fit_transform(data)
# 反归一化预测结果 6 是X的特征维度
prediction_copies_array = np.repeat(predicted.detach().cpu().numpy(), 6, axis=-1)
predicted_cpu = predicted.detach().cpu().numpy()
predicted_np = scaler.inverse_transform(
np.reshape(prediction_copies_array, (len(predicted_cpu), 6))
)[:, 0]
y_test_copies_array = np.repeat(y_test_tensor.detach().cpu().numpy(), 6, axis=-1)
y_test_cpu = y_test_tensor.detach().cpu().numpy()
y_test_np = scaler.inverse_transform(
np.reshape(y_test_copies_array, (len(y_test_cpu), 6))
)[:, 0]conda install pytorch torchvision torchaudio pytorch-cuda=12.4 -c pytorch -c nvidiacheck
import torch
print(torch.cuda.is_available())Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/
.\vs_buildtools.exe --norestart --passive --downloadThenInstall --includeRecommended --add Microsoft.VisualStudio.Workload.NativeDesktop --add Microsoft.VisualStudio.Workload.VCTools --add Microsoft.VisualStudio.Workload.MSBuildToolsgit clone https://mirrors4.tuna.tsinghua.edu.cn/git/ohmyzsh.git
cd ohmyzsh/tools
REMOTE=https://mirrors4.tuna.tsinghua.edu.cn/git/ohmyzsh.git sh install.shcd ~
vim .condarcchannels:
- defaults
show_channel_urls: true
default_channels:
- https://mirror.bjtu.edu.cn/anaconda/pkgs/main
- https://mirror.bjtu.edu.cn/anaconda/pkgs/r
- https://mirror.bjtu.edu.cn/anaconda/pkgs/msys2
custom_channels:
conda-forge: https://mirror.bjtu.edu.cn/anaconda/cloud
pytorch: https://mirror.bjtu.edu.cn/anaconda/cloudpip config set global.index-url https://mirrors.bfsu.edu.cn/pypi/web/simplehttps://mirrors.bfsu.edu.cn/help
need add to last with .bashrc or .zshrc
# wsl2 proxy
# export hostip=$(cat /etc/resolv.conf |grep -oP '(?<=nameserver\ ).*')
export hostip=127.0.0.1
#export https_proxy="http://${hostip}:7897"
#export http_proxy="http://${hostip}:7897"
#export all_proxy="socks5://${hostip}:7897"
#export ALL_PROXY="socks5://${hostip}:7897"
# 默认不开启代理,可通过unproxy 和proxy 别名命令 关闭或开启代理
alias proxy='export https_proxy="http://${hostip}:7897";export http_proxy="http://${hostip}:7897";export all_proxy="socks5://${hostip}:7897";export ALL_PROXY="socks5://${hostip}:7897";'
alias unproxy='unset https_proxy; unset http_proxy; unset all_proxy; unset ALL_PROXY;'if you use .wslconfig with experimental you need change hostip=127.0.0.1
[wsl2]
[experimental]
networkingMode=mirroredmkdir -p ~/miniconda3
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O ~/miniconda3/miniconda.sh
bash ~/miniconda3/miniconda.sh -b -u -p ~/miniconda3
rm -rf ~/miniconda3/miniconda.sh
~/miniconda3/bin/conda init bash
~/miniconda3/bin/conda init zshsolution page:microsoft/WSL#4177 (comment)
save code like fix_wsl.ps1, then run it with powershell administrator .\fix_wsl.ps1
#Requires -RunAsAdministrator
# Fix for https://github.com/microsoft/WSL/issues/4177
$MethodDefinition = @'
[DllImport("ws2_32.dll", CharSet = CharSet.Unicode)]
public static extern int WSCSetApplicationCategory([MarshalAs(UnmanagedType.LPWStr)] string Path, uint PathLength, [MarshalAs(UnmanagedType.LPWStr)] string Extra, uint ExtraLength, uint PermittedLspCategories, out uint pPrevPermLspCat, out int lpErrno);
'@
$Ws2Spi = Add-Type -MemberDefinition $MethodDefinition -Name 'Ws2Spi' -PassThru
$WslLocation = Get-AppxPackage MicrosoftCorporationII.WindowsSubsystemForLinux | Select-Object -expand InstallLocation
$Executables = ("wsl.exe", "wslservice.exe");
foreach ($Exe in $Executables) {
$ExePath = "${WslLocation}\${Exe}";
$ExePathLength = $ExePath.Length;
$PrevCat = $null;
$ErrNo = $null;
if ($Ws2Spi::WSCSetApplicationCategory($ExePath, $ExePathLength, $null, 0, [uint32]"0x80000000", [ref] $PrevCat, [ref] $ErrNo) -eq 0) {
Write-Output "Added $ExePath!";
}
}then
taskkill -IM "wslservice.exe" /Ffrom selenium import webdriver
from selenium.webdriver.edge.service import Service as EdgeService
from webdriver_manager.microsoft import EdgeChromiumDriverManager
option = webdriver.EdgeOptions()
# make sure change C:/Users/chen/AppData/Local/Microsoft/Edge/User Data to your own profile address,you can find it with edge in edge://version
option.add_argument("user-data-dir=C:/Users/chen/AppData/Local/Microsoft/Edge/User Data")
option.add_argument("--start-maximized")
driver = webdriver.Edge(service=EdgeService(EdgeChromiumDriverManager().install()),options=option)

