create_shortcut.ps1
function Create-Shortcuts {
param (
[string]$TargetPath1,
[string]$LnkName
)
$fileName = [System.IO.Path]::GetFileName("$TargetPath1")
$shell = New-Object -ComObject WScript.Shell
$desktop = [System.Environment]::GetFolderPath('Desktop')
$shortcut1 = $shell.CreateShortcut("$desktop\$fileName.lnk")
$shortcut1.TargetPath = $TargetPath1
$shortcut1.Save()
}
# 调用方法示例
Create-Shortcuts -TargetPath1 "D:\software\Notepad++\notepad++.exe"
Create-Shortcuts -TargetPath1 "D:\software\WinRAR5.0\WINRAR.EXE"
Create-Shortcuts -TargetPath1 "D:\software\00.快捷方式"
Create-Shortcuts -TargetPath1 "D:\software\FastStone Capture\FSCapture.exe"