How to write shortcut (.lnk) files to the "Recent" folder

YLML 0 Reputation points
2023-06-14T14:02:29.3366667+00:00

How to write a shortcut (.lnk) file to the C:\Users\Lenovo\AppData\Roaming\Microsoft\Windows\Recent folder

I need to batch insert files into the "Recent" that pops up after right-clicking on the taskbar to fix files to quick access, but I don't want to open these files.

图片

图片

I have tried to modify the properties of the folder and use the Administrator account to obtain permissions in safe mode, but it has no effect.c1e1ecc0-59d9-46aa-8764-d6876e9a586f

Windows for business | Windows Client for IT Pros | User experience | Other
0 comments No comments
{count} votes

3 answers

Sort by: Most helpful
  1. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more

  2. Khaled Elsayed Mohamed 1,335 Reputation points
    2023-06-15T09:47:14.3733333+00:00

    or by using PowerShell script:

    $targetFolderPath = "C:\Users\Lenovo\AppData\Roaming\Microsoft\Windows\Recent"
    
    # Create an array of shortcut names and target paths
    $shortcuts = @{
        "Shortcut1" = "C:\Path\to\Target1.exe"
        "Shortcut2" = "C:\Path\to\Target2.exe"
        "Shortcut3" = "C:\Path\to\Target3.exe"
    }
    
    # Loop through the shortcuts and create .lnk files
    $shell = New-Object -ComObject WScript.Shell
    
    foreach ($shortcut in $shortcuts.GetEnumerator()) {
        $shortcutName = $shortcut.Key
        $targetPath = $shortcut.Value
    
        $shortcutFilePath = Join-Path -Path $targetFolderPath -ChildPath "$shortcutName.lnk"
    
        $shortcutObject = $shell.CreateShortcut($shortcutFilePath)
        $shortcutObject.TargetPath = $targetPath
        $shortcutObject.Save()
    
        Write-Host "Shortcut '$shortcutName' created at '$shortcutFilePath'"
    }
    

    Make sure to replace the values in the $targetFolderPath variable with the actual path to the "Recent" folder, and update the $shortcuts hashtable with the desired shortcut names and their corresponding target paths.

    Save the script with a .ps1 extension (e.g., create-shortcuts.ps1), and then you can run it by opening PowerShell and executing the script using the following command:

    .\create-shortcuts.ps1
    

    The script will iterate through the $shortcuts hashtable, create a .lnk file for each shortcut name and target path, and save it in the specified folder. It will also display a message for each created shortcut with its name and file path.

    0 comments No comments

  3. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.