Skip to content

Commit f269c93

Browse files
CopilotRomanitho
andcommitted
Add comment-based help documentation to Add-ProgramsShortcuts function
Co-authored-by: Romanitho <96626929+Romanitho@users.noreply.github.com>
1 parent 8b43532 commit f269c93

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

Sources/Winget-AutoUpdate/mods/_Mods-Functions.ps1

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,41 @@ function Remove-ModsLnk ($Lnk) {
185185
Return $removedCount
186186
}
187187

188+
<#
189+
.SYNOPSIS
190+
Creates Start Menu shortcuts for applications.
191+
192+
.DESCRIPTION
193+
Creates shortcuts (.lnk files) in the Start Menu Programs folder
194+
for specified applications. Supports subdirectories in shortcut names
195+
and validates that target files exist before creating shortcuts.
196+
197+
.PARAMETER Shortcuts
198+
Array of shortcut names (without .lnk extension). Supports subdirectories
199+
using backslash (e.g., "Folder\ShortcutName"). Must match the length and
200+
order of the ShortcutsTargets array.
201+
202+
.PARAMETER ShortcutsTargets
203+
Array of full paths to target executables or files. Must match the length
204+
and order of the Shortcuts array.
205+
206+
.OUTPUTS
207+
Integer count of shortcuts successfully created.
208+
209+
.EXAMPLE
210+
Add-ProgramsShortcuts @("MyApp") @("C:\Program Files\MyApp\MyApp.exe")
211+
Creates a shortcut named "MyApp.lnk" in the Start Menu Programs folder.
212+
213+
.EXAMPLE
214+
Add-ProgramsShortcuts @("Tools\dnGrep") @("${env:ProgramFiles}\dnGrep\dnGrep.exe")
215+
Creates a shortcut in the "Tools" subfolder of the Start Menu Programs folder.
216+
217+
.EXAMPLE
218+
$shortcuts = @("App1", "Folder\App2")
219+
$targets = @("C:\Apps\App1.exe", "C:\Apps\App2.exe")
220+
Add-ProgramsShortcuts $shortcuts $targets
221+
Creates multiple shortcuts, with App2 placed in a subfolder.
222+
#>
188223
function Add-ProgramsShortcuts ($Shortcuts, $ShortcutsTargets) {
189224
$programsPath = "${env:ProgramData}\Microsoft\Windows\Start Menu\Programs"
190225
$createdCount = 0

0 commit comments

Comments
 (0)