注册表
可以使用Autoruns软件 可以方便的跳转注册表
regedit 打开注册表, 定位以下路径
HKCU\Software\Microsoft\Windows\CurrentVersion\Run
添加字符串值, 填名称和对应脚本路径
启动文件夹
按 Win + R 输入 shell:startup 回车
C:\Users\Administrator\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup
添加需要自启动的快捷方式
同步配置
添加到注册表 每天自动执行
# 执行: powershell D:\\sync.ps1
# 定义文件到目录的映射
$mappings = @{
# Git配置
"C:\Users\Administrator\.gitconfig" = "D:\Config\Git\_gitconfig"
}
# 延迟3分钟执行
Start-Sleep -Seconds 180
foreach ($src in $mappings.Keys) {
$dst = $mappings[$src]
if (Test-Path $src -PathType Leaf) {
# 确保目标目录存在
if (-not (Test-Path $dst)) {
New-Item -ItemType Directory -Path $dst -Force | Out-Null
}
try {
Copy-Item -Path $src -Destination $dst -Force -ErrorAction Stop
Write-Host "Copied: $src -> $dst" -ForegroundColor Green
} catch {
Write-Host "Copy Fail: $src - $_" -ForegroundColor Red
}
} else {
Write-Host "Skip(Not Exist): $src" -ForegroundColor Yellow
}
}