@@ -185,6 +185,54 @@ function Remove-ModsLnk ($Lnk) {
185185 Return $removedCount
186186}
187187
188+ function Add-ProgramsShortcuts ($Shortcuts , $ShortcutsTargets ) {
189+ $programsPath = " ${env: ProgramData} \Microsoft\Windows\Start Menu\Programs"
190+ $createdCount = 0
191+
192+ # Validate arrays match in length
193+ if ($Shortcuts.Count -ne $ShortcutsTargets.Count ) {
194+ Return $createdCount
195+ }
196+
197+ # Create WScript.Shell COM object
198+ $WshShell = New-Object - ComObject WScript.Shell - ErrorAction SilentlyContinue
199+ if (! $WshShell ) {
200+ Return $createdCount
201+ }
202+
203+ # Iterate through shortcuts
204+ for ($i = 0 ; $i -lt $Shortcuts.Count ; $i ++ ) {
205+ $shortcutName = $Shortcuts [$i ]
206+ $targetPath = $ShortcutsTargets [$i ]
207+
208+ # Skip empty entries
209+ if ([string ]::IsNullOrEmpty($shortcutName ) -or [string ]::IsNullOrEmpty($targetPath )) {
210+ continue
211+ }
212+
213+ # Construct full shortcut path
214+ $shortcutPath = Join-Path $programsPath " $shortcutName .lnk"
215+
216+ # Create parent directory if it doesn't exist
217+ $shortcutDir = Split-Path $shortcutPath - Parent
218+ if (! (Test-Path $shortcutDir )) {
219+ New-Item - Path $shortcutDir - ItemType Directory - Force - ErrorAction SilentlyContinue | Out-Null
220+ }
221+
222+ # Verify target exists
223+ if (Test-Path $targetPath ) {
224+ # Create shortcut
225+ $shortcut = $WshShell.CreateShortcut ($shortcutPath )
226+ $shortcut.TargetPath = $targetPath
227+ $shortcut.WorkingDirectory = Split-Path $targetPath - Parent
228+ $shortcut.Save ()
229+ $createdCount ++
230+ }
231+ }
232+
233+ Return $createdCount
234+ }
235+
188236function Add-ModsReg ($AddKey , $AddValue , $AddTypeData , $AddType ) {
189237 if ($AddKey -like " HKEY_LOCAL_MACHINE*" ) {
190238 $AddKey = $AddKey.replace (" HKEY_LOCAL_MACHINE" , " HKLM:" )
0 commit comments