{"id":10543,"date":"2019-07-31T11:33:39","date_gmt":"2019-07-31T11:33:39","guid":{"rendered":"http:\/\/198.58.113.91\/blog\/?p=10543"},"modified":"2022-10-31T21:06:17","modified_gmt":"2022-10-31T15:36:17","slug":"how-to-change-shortcut-lnk-targets-in-bulk-using-script","status":"publish","type":"post","link":"https:\/\/www.winhelponline.com\/blog\/how-to-change-shortcut-lnk-targets-in-bulk-using-script\/","title":{"rendered":"How to Change Shortcut (.lnk) Target in Bulk Using Script"},"content":{"rendered":"<p>Many users have shortcuts pointing to various network shares from other systems or your domain&#8217;s storage server. If your company migrates the server and changes the computer name, share name, or folder path, you need to manually update the shortcut targets to point to the right destination. In most cases, the folder structure may remain the same, but the server name usually changes.<!--more--><\/p>\n<p>For shortcuts pointing to a file or folder in the local machine, Windows updates the shortcuts automatically (using the &#8220;Distributed Link Tracking&#8221; service) when the target is moved or renamed. But, in the case of shortcuts pointing to network locations, they have to be done manually or using a program\/script.<\/p>\n<p>Updating the paths manually is tiring, especially if you have hundreds of shortcuts. This article has three methods to bulk update shortcut targets and\/or arguments.<\/p>\n<h2>Change Shortcut (.lnk) Targets in Bulk<\/h2>\n<p>Pick one of the following options to bulk update shortcuts. Before proceeding, it&#8217;s advisable to backup the old shortcuts before the bulk update procedure, just in case you accidentally specify a wrong path in the utility or script file.<\/p>\n<h3>Option 1: Using the &#8220;Shortcut Search And Replace&#8221; tool<\/h3>\n<p>&#8220;Shortcut Search And Replace&#8221; from Jacquelin POTIER is an extremely useful utility that can bulk update shortcuts. It can update the shortcut target, arguments, as well as the working directory.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-29052\" src=\"https:\/\/www.winhelponline.com\/blog\/wp-content\/uploads\/2019\/07\/shortcut-search-replace.png\" alt=\"shortcuts search and replace bulk\" width=\"767\" height=\"504\" \/><\/p>\n<p>This utility provides so many options, of which some are mentioned below:<\/p>\n<ul>\n<li>Include the custom extra &#8220;Search Folder&#8221; for search and replace operations.<\/li>\n<li>To include sub-directories, check the &#8220;Include subdirectories option&#8221;.<\/li>\n<li>&#8220;Applies To&#8221;: Options to select which part of the shortcut is affected (multiple options can be checked)\n<ul>\n<li>Include shortcut target directory into search and replace operations. (Target file name not included, so you can change directory without affecting name). Note that this option also updates the working directory (if it matches.)<\/li>\n<li>Include shortcut target file name into search and replace operations. (Target directory not affected)<\/li>\n<li>Include shortcut icon directory into search and replace operations. (Target icon file name not included, so you can change icon directory without affecting icon name)<\/li>\n<li>Include shortcut icon file name into search and replace operations. (Target icon directory not affected)<\/li>\n<li>Include shortcut arguments into search and replace operations<\/li>\n<li>Replace only the arguments matching the inputted target path (discard all other replace operations.)<\/li>\n<li>Include comments in search and replace operations.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>This tool has a <strong>command-line feature<\/strong> as well.\u00a0<span style=\"font-size: inherit;\">For more information, read the .chm help file supplied with this tool. You can download &#8216;Shortcuts Search And Replace&#8217; from the following link:<\/span><\/p>\n<pre>http:\/\/jacquelin.potier.free.fr\/ShortcutsSearchAndReplace\/<\/pre>\n<hr \/>\n<h3>Option 2: Using VBScript<\/h3>\n<p>The following VBScript updates shortcuts containing a specified target path to the new target path. Also, it updates the old paths in shortcut arguments as well as the &#8220;Start in&#8221; directory.<\/p>\n<p><script src=\"https:\/\/gist.github.com\/winhelponline\/f20e25ba87b24f7e0784f8b9fc26594d.js\"><\/script><\/p>\n<h4>How to Use:<\/h4>\n<ol>\n<li>Save the above script to a permanent folder.<\/li>\n<li>Open the script using Notepad and edit the old path and new path accordingly in Line #27 and #28. Save the file and close it.<\/li>\n<li>Open your <code>SendTo<\/code> folder by running <strong>shell:sendto<\/strong> in Start\/Run dialog.<\/li>\n<li>Place a shortcut to the above script in the <code>SendTo<\/code> folder and name it suitably &#8212; e.g., Update Shortcuts.<\/li>\n<li>Select one or more shortcuts you want to update, click Send To, and click &#8220;Update Shortcuts&#8221;.<\/li>\n<\/ol>\n<p>That&#8217;s it. The script enumerates each shortcut, updates the paths accordingly, and outputs the result to a log file. Here&#8217;s a sample log:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-28889\" src=\"https:\/\/www.winhelponline.com\/blog\/wp-content\/uploads\/2019\/07\/shortcut-bulk-update-log.png\" alt=\"bulk update shortcuts script - log file\" width=\"1098\" height=\"1040\" srcset=\"https:\/\/www.winhelponline.com\/blog\/wp-content\/uploads\/2019\/07\/shortcut-bulk-update-log.png 1098w, https:\/\/www.winhelponline.com\/blog\/wp-content\/uploads\/2019\/07\/shortcut-bulk-update-log-768x727.png 768w\" sizes=\"auto, (max-width: 1098px) 100vw, 1098px\" \/><\/p>\n<hr \/>\n<h3>Option 3: Using PowerShell<\/h3>\n<p>Here is a PowerShell script that automatically updates the shortcut target for .lnk files in a specified folder. This script automatically updates shortcuts that contain the old server name or path, replacing them with the new name or path.<\/p>\n<p><strong>Note:<\/strong> The following script doesn&#8217;t modify the old path name in arguments and the &#8220;Start in&#8221; directory.<\/p>\n<pre>$oldPrefix = \"\\\\MEDIA\"\r\n$newPrefix = \"\\\\MEDIA-PC\"\r\n$searchPath = \"E:\\Shortcuts\"\r\n\r\n$shell = new-object -com wscript.shell\r\nwrite-host \"Updating shortcut target\" -foregroundcolor red -backgroundcolor black\r\n\r\ndir $searchPath -filter *.lnk -recurse | foreach {\r\n$lnk = $shell.createShortcut( $_.fullname )\r\n$oldPath= $lnk.targetPath\r\n$lnkRegex = \"^\" + [regex]::escape( $oldPrefix )\r\n\r\nif ( $oldPath -match $lnkRegex ) {\r\n$newPath = $oldPath -replace $lnkRegex, $newPrefix\r\n\r\nwrite-host \"Found: \" + $_.fullname -foregroundcolor yellow -backgroundcolor black\r\nwrite-host \" Replace: \" + $oldPath\r\nwrite-host \" With: \" + $newPath\r\n$lnk.targetPath = $newPath\r\n$lnk.Save()\r\n}\r\n}<\/pre>\n<ol>\n<li>Copy the above code to Notepad, and save the file as <code>lnk_change.ps1<\/code><\/li>\n<li>Make sure you input the old and new paths in lines 1 &amp; 2 above.<\/li>\n<li>In line #3, specify the folder which stores the shortcuts for which you want to update the path.<\/li>\n<li>From the Run dialog, execute the following command:\n<pre>powershell -noexit -ExecutionPolicy ByPass -File D:\\Scripts\\lnk_change.ps1<\/pre>\n<p><span style=\"background-color: rgba(0, 0, 0, 0.05); font-family: inherit; font-size: inherit;\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-10544\" style=\"background-color: #ffffff;\" src=\"https:\/\/www.winhelponline.com\/blog\/wp-content\/uploads\/2019\/07\/bulk-shortcut-path-change.png\" alt=\"change shortcut .lnk target in bulk\" width=\"700\" height=\"307\" \/><br \/>\n<\/span><\/li>\n<\/ol>\n<p>That&#8217;s it. The shortcut targets are now updated from <code>\\\\MEDIA<\/code> to <code>\\\\MEDIA-PC<\/code>.<\/p>\n<ul>\n<li>You can also use the full path to the resource, such as <code>\\\\MEDIA\\Shared<\/code> and <code>\\\\MEDIA-PC\\SharedFolder<\/code> as the &#8220;old&#8221; and &#8220;new&#8221; paths respectively.<\/li>\n<li>In case the server name is the same but the folder path has changed, you must input the full paths in line numbers 1 &amp; 2 respectively &#8212; e.g., <code>\\\\MEDIA\\Shared<\/code> to <code>\\\\MEDIA\\SharedFolder<\/code><\/li>\n<\/ul>\n<p>Hope that helps!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Many users have shortcuts pointing to various network shares from other systems or your domain&#8217;s storage server. If your company migrates the server and changes the computer name, share name, or folder path, you need to manually update the shortcut targets to point to the right destination. In most cases, the folder structure may remain &#8230; <a title=\"How to Change Shortcut (.lnk) Target in Bulk Using Script\" class=\"read-more\" href=\"https:\/\/www.winhelponline.com\/blog\/how-to-change-shortcut-lnk-targets-in-bulk-using-script\/\" aria-label=\"Read more about How to Change Shortcut (.lnk) Target in Bulk Using Script\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_post_was_ever_published":false},"categories":[6,7],"tags":[876,396,480],"class_list":["post-10543","post","type-post","status-publish","format-standard","hentry","category-utilities","category-windows","tag-gist","tag-powershell","tag-scripts"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack-related-posts":[{"id":273,"url":"https:\/\/www.winhelponline.com\/blog\/add-the-open-file-location-context-menu-for-shortcuts-in-windows-xp\/","url_meta":{"origin":10543,"position":0},"title":"How to Add &#8220;Open File Location&#8221; Right-Click Option in Windows XP","author":"Ramesh","date":"May 9, 2008","format":false,"excerpt":"Windows Vista and Windows 7 include the Open file location context menu item for Shortcuts, which helps you quickly open the target folder of a shortcut. In Windows XP, it takes four mouse clicks to accomplish the task. To open the target folder of a shortcut in Windows XP, you\u2026","rel":"","context":"In &quot;Windows XP&quot;","block_context":{"text":"Windows XP","link":"https:\/\/www.winhelponline.com\/blog\/category\/microsoft\/windows\/windows-xp\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/opentargetdir.gif?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":75329,"url":"https:\/\/www.winhelponline.com\/blog\/refresh-thumbnails-folder-shortcuts\/","url_meta":{"origin":10543,"position":1},"title":"How to Refresh Thumbnails of Folder Shortcuts (.lnk)","author":"Ramesh","date":"May 31, 2024","format":false,"excerpt":"When you create a desktop shortcut to a folder, the folder shortcut thumbnail icon reflects what was in the folder it points to at creation. Later, when you add or remove files to the target folder, the folder thumbnails get updated dynamically, but the folder shortcut thumbnails remain the same.\u2026","rel":"","context":"In &quot;Windows 10&quot;","block_context":{"text":"Windows 10","link":"https:\/\/www.winhelponline.com\/blog\/category\/microsoft\/windows\/windows-10\/"},"img":{"alt_text":"folder shortcut thumbnails not refreshing","src":"https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/2024\/05\/folder-shortcut-thumbnail.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":1693,"url":"https:\/\/www.winhelponline.com\/blog\/restore-admin-tools-shortcuts-windows-10\/","url_meta":{"origin":10543,"position":2},"title":"Restore Missing Administrative Tools Shortcuts in Windows 10","author":"Ramesh","date":"February 28, 2016","format":false,"excerpt":"The Administrative Tools folder in the Start menu contains a list of shortcuts to launch admin tools like Perfmon, Resmon, Computer Management, Registry Editor, etc.\u00a0If your Administrative Tools folder is empty, use one of these ways to restore the default shortcuts. Method 1: Restore missing shortcuts using SFC The default\u2026","rel":"","context":"In &quot;Windows 10&quot;","block_context":{"text":"Windows 10","link":"https:\/\/www.winhelponline.com\/blog\/category\/microsoft\/windows\/windows-10\/"},"img":{"alt_text":"admin tools shortcuts sfc.","src":"https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/2016\/02\/sfc-scanfile-admin-tools.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/2016\/02\/sfc-scanfile-admin-tools.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/2016\/02\/sfc-scanfile-admin-tools.png?resize=525%2C300&ssl=1 1.5x"},"classes":[]},{"id":4654,"url":"https:\/\/www.winhelponline.com\/blog\/pin-website-shortcut-start-screen-windows-10\/","url_meta":{"origin":10543,"position":3},"title":"Pin a Website Shortcut to the Windows 10 Start Menu","author":"Ramesh","date":"November 23, 2016","format":false,"excerpt":"If you've been using desktop shortcuts to open your favorite websites, you can instead pin those websites to the Windows 10 Start menu to make your desktop clutter-free. Moreover, pinning websites to the Start screen helps you get to those sites quickly especially when your Windows 10 device is in\u2026","rel":"","context":"In &quot;Internet Explorer&quot;","block_context":{"text":"Internet Explorer","link":"https:\/\/www.winhelponline.com\/blog\/category\/microsoft\/internet-explorer\/"},"img":{"alt_text":"pin website shortcuts to start screen windows 10","src":"https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/2016\/11\/pin-website-start-screen-11.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/2016\/11\/pin-website-start-screen-11.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/2016\/11\/pin-website-start-screen-11.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/2016\/11\/pin-website-start-screen-11.png?resize=700%2C400&ssl=1 2x"},"classes":[]},{"id":3116,"url":"https:\/\/www.winhelponline.com\/blog\/list-all-hotkeys-used-shortcuts-script\/","url_meta":{"origin":10543,"position":4},"title":"List All Assigned Shortcut Keys for Shortcuts on Windows","author":"Ramesh","date":"May 15, 2016","format":false,"excerpt":"If you're not able to assign a particular hotkey combination for a shortcut, then it may have already been registered. But which shortcut is currently using the hotkey, and from which folder path? You can find it out by running the script attached to this article. ListHotKeys.vbs Script This script\u2026","rel":"","context":"In &quot;Windows&quot;","block_context":{"text":"Windows","link":"https:\/\/www.winhelponline.com\/blog\/category\/microsoft\/windows\/"},"img":{"alt_text":"hotkeyslist","src":"https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/2016\/05\/hotkeyslist-nirsoft.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/2016\/05\/hotkeyslist-nirsoft.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/2016\/05\/hotkeyslist-nirsoft.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/2016\/05\/hotkeyslist-nirsoft.png?resize=700%2C400&ssl=1 2x"},"classes":[]},{"id":142,"url":"https:\/\/www.winhelponline.com\/blog\/fix-overlapping-icon-windows-7-vista\/","url_meta":{"origin":10543,"position":5},"title":"Desktop Icons Covered with White Boxes or Black Squares","author":"Ramesh","date":"April 2, 2008","format":false,"excerpt":"Here is a mysterious case of the icon overlap problem, which the screenshot below explains perfectly. You can see the original icon for shortcuts is overlapped by a generic white overlay (shown for unknown file types). An incorrect icon overlay setting is causing the problem. As the issue is seen\u2026","rel":"","context":"In &quot;Windows&quot;","block_context":{"text":"Windows","link":"https:\/\/www.winhelponline.com\/blog\/category\/microsoft\/windows\/"},"img":{"alt_text":"shortcuts covered by white icon","src":"https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/2008\/04\/icon-overlap-shellicons-2.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/2008\/04\/icon-overlap-shellicons-2.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/2008\/04\/icon-overlap-shellicons-2.png?resize=525%2C300&ssl=1 1.5x"},"classes":[]}],"_links":{"self":[{"href":"https:\/\/www.winhelponline.com\/blog\/wp-json\/wp\/v2\/posts\/10543","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.winhelponline.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.winhelponline.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.winhelponline.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.winhelponline.com\/blog\/wp-json\/wp\/v2\/comments?post=10543"}],"version-history":[{"count":0,"href":"https:\/\/www.winhelponline.com\/blog\/wp-json\/wp\/v2\/posts\/10543\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.winhelponline.com\/blog\/wp-json\/wp\/v2\/media?parent=10543"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.winhelponline.com\/blog\/wp-json\/wp\/v2\/categories?post=10543"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.winhelponline.com\/blog\/wp-json\/wp\/v2\/tags?post=10543"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}