|
本帖最后由 倒垃圾的歌者 于 2025-9-22 09:38 编辑
不用担心,PowerShell也可以创建快捷方式
- @echo off & setlocal enabledelayedexpansion
- :: 设置快捷方式参数
- set "TargetPath=C:\Windows\System32\notepad.exe"
- set "ShortcutPath=%UserProfile%\Desktop\记事本.lnk"
- set "Arguments=C:\Windows\System32\drivers\etc\hosts"
- set "WorkingDir=C:\Windows\System32"
- set "Hotkey=Ctrl+Alt+N"
- set "Description=用记事本打开hosts文件"
- set "IconLocation=C:\Windows\System32\notepad.exe,0"
- set "WindowStyle=1" :: 1=正常窗口, 3=最大化, 7=最小化
- :: 调用PowerShell创建快捷方式
- powershell -command "$ws = New-Object -ComObject WScript.Shell; $s = $ws.CreateShortcut('%ShortcutPath%'); $s.TargetPath = '%TargetPath%'; $s.Arguments = '%Arguments%'; $s.WorkingDirectory = '%WorkingDir%'; $s.Hotkey = '%Hotkey%'; $s.Description = '%Description%'; $s.IconLocation = '%IconLocation%'; $s.WindowStyle = %WindowStyle%; $s.Save()"
- echo 快捷方式已创建:%ShortcutPath%
- echo 配置详情:
- echo 目标:%TargetPath%
- echo 参数:%Arguments%
- echo 起始位置:%WorkingDir%
- echo 快捷键:%Hotkey%
- echo 备注:%Description%
- echo 图标:%IconLocation%
- echo 运行方式:!WindowStyle!
- pause
复制代码 |
|