管理 Windows 上的 .lnk 快捷方式文件。核心操作通过 PowerShell + WScript.Shell COM 组件实现,支持扫描、创建、校验、修复、重命名、导出/导入等批量操作。
| 操作 | 说明 |
|---|---|
| ------ | ------ |
| 列出快捷方式 | 扫描指定目录的所有 .lnk 文件,显示目标路径、参数、图标等信息 |
| 检测失效链接 | 找出目标文件不存在或无访问权限的失效快捷方式 |
| 批量创建 | 从 JSON/CSV 配置文件批量生成快捷方式 |
| 批量修复 | 对失效快捷方式尝试自动查找正确目标路径 |
| 重命名 | 按规则批量重命名快捷方式文件 |
| 导出/导入 | 将快捷方式配置导出为 JSON,支持备份和迁移 |
所有脚本位于 skills/shortcut-manager/scripts/ 目录下。
扫描目录中所有 .lnk 文件并显示详细信息。
powershell -ExecutionPolicy Bypass -File "scripts/list-shortcuts.ps1" -Path "C:\Users\Public\Desktop"
可选参数:
-Path <路径>:要扫描的目录(必填)-Recurse:递归扫描子目录-OutputJson <文件路径>:导出结果为 JSON找出目标文件不存在或无法访问的快捷方式。
powershell -ExecutionPolicy Bypass -File "scripts/find-broken.ps1" -Path "C:\Users\Public\Desktop" -Recurse
可选参数:
-Path <路径>:扫描目录-Recurse:递归扫描-AutoFix:尝试自动修复-Delete:删除确认无目标的失效快捷方式-ReportPath <文件路径>:输出报告从 JSON 配置文件批量创建快捷方式。JSON 格式:
[
{
"name": "VS Code",
"target": "C:\\Users\\UserName\\AppData\\Local\\Programs\\Microsoft VS Code\\Code.exe",
"arguments": "",
"workingDirectory": "C:\\Users\\UserName",
"iconLocation": "C:\\Users\\UserName\\AppData\\Local\\Programs\\Microsoft VS Code\\Code.exe,0",
"description": "Visual Studio Code",
"hotkey": "",
"windowStyle": 1,
"locations": [
"C:\\Users\\Public\\Desktop",
"C:\\Users\\UserName\\AppData\\Roaming\\Microsoft\\Windows\\Start Menu\\Programs"
]
}
]
powershell -ExecutionPolicy Bypass -File "scripts/batch-create.ps1" -Config "C:\path\to\shortcuts.json"
将目录中所有快捷方式的信息导出为 JSON,用于备份或迁移。
powershell -ExecutionPolicy Bypass -File "scripts/export-shortcuts.ps1" -Path "C:\Users\Public\Desktop" -Output "shortcuts-backup.json"
按正则替换规则批量重命名快捷方式。
powershell -ExecutionPolicy Bypass -File "scripts/rename-shortcuts.ps1" -Path "C:\Users\Public\Desktop" -Pattern "旧名称" -Replacement "新名称"
验证快捷方式目标的完整性和安全性,检测可疑目标。
powershell -ExecutionPolicy Bypass -File "scripts/validate-shortcuts.ps1" -Path "C:\Users\Public\Desktop"
共 1 个版本