How to add many any programs to the list of installed programs

Smalllbuddy

New Member
Joined
Apr 23, 2024
I've made a PowerShell command which takes all the shortcuts in the folder you direct it to, and it makes registry keys for them so that they show up as installed apps. They get an appropriate icon and name.

You can uninstall it to, HOWEVER uninstalling it simply removes the registry key so it's no longer in installed programs, and it DOESNT remove the containing folder. I decided it'd be better this way, as someone may decide that they want to remove the registry key, and so this will be easier for them.

If you want a version where uninstalling will remove the folder that the shortcut points too, leave a comment and I'll make it for you. Thanks!

WARNING

MAKE SURE TO RUN POWERSHELL AS ADMIN

MAKE SURE TO REPLACE THE TOP LINE "C:\SHORTCUTFOLDER" WITH THE DIRECTORY YOU PREFER

THIS DOES MODIFY REGISTRY. IT IS ALWAYS SAFE TO BACKUP REGISTRY FIRST.



$shortcutFolder = "C:\ShortcutFolder" # Specify the folder containing the shortcuts

# Loop through shortcuts to create registry keys
foreach ($shortcut in Get-ChildItem -Path $shortcutFolder -Filter "*.lnk") {
$shortcutName = $shortcut.BaseName

# Get the target path and icon location of the shortcut
$shell = New-Object -ComObject WScript.Shell
$shortcutObject = $shell.CreateShortcut($shortcut.FullName)
$shortcutPath = $shortcutObject.TargetPath
$shortcutIcon = $shortcutObject.IconLocation
$publisher = "Uninstall removes registry. Program is untouched."

# Check if the shortcut specifies an icon
if ($shortcutIcon -ne ",0") {
# Attempt to use the icon specified in the shortcut
$icon = $shortcutIcon
} else {
# Fall back to extracting icon from the executable file
$icon = $shortcutPath
}

# Create registry key for the shortcut under WOW6432Node
$keyPath = "HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\$shortcutName"

if (-not (Test-Path $keyPath)) {
# If the registry key doesn't exist, create it
New-Item -Path $keyPath -Force

# Set DisplayName value to the shortcut name
Set-ItemProperty -Path $keyPath -Name "DisplayName" -Value $shortcutName

# Set publisher value
Set-ItemProperty -Path $keyPath -Name "Publisher" -Value $publisher

# Set UninstallString value to execute uninstallation logic directly
$uninstallCommand = "REG DELETE `"HKLM\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\$shortcutName`" /f"
$uninstallString = "cmd.exe /c $uninstallCommand"
Set-ItemProperty -Path $keyPath -Name "UninstallString" -Value $uninstallString

# Set DisplayIcon value to the icon extracted from the shortcut or executable
Set-ItemProperty -Path $keyPath -Name "DisplayIcon" -Value $icon
}
}
 
Last edited:
Back
Top Bottom