{"id":163,"date":"2022-08-30T18:55:34","date_gmt":"2022-08-30T18:55:34","guid":{"rendered":"https:\/\/tutorialized.com\/?p=163"},"modified":"2022-08-31T20:05:27","modified_gmt":"2022-08-31T20:05:27","slug":"1-44","status":"publish","type":"post","link":"https:\/\/tutorialized.com\/view\/tutorial\/1-44\/","title":{"rendered":"Visual Basic: Extract the Target file from a shortcut file .lnk Tutorial"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Here&#8217;s a tutorial for using Visual Basic to extract the target file from a shortcut file. This is helpful when you have shortcuts that point to a folder where a new file has been added since the last time you checked.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">What is a shortcut file?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">A shortcut file is a file that contains a list of shortcuts that you can use to open files or folders. When you double-click a shortcut file, Windows launches the programs in the list, exactly as if you had typed the full path to the file or folder.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If you want to delete a shortcut file, right-click it and choose &#8216;Remove Shortcut.&#8217; Add a shortcut file to the Desktop. Right-click an empty area on the desktop and choose New &gt; Shortcut.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In the &#8216;Type&#8217; text box, type a name and then press Enter. In this example, we will call our new shortcut file My JPG Files. In the &#8216;Location&#8217; text box, type %USERPROFILE%DesktopMy JPG Files (make sure you include the double backslashes at the end of your filename) and then press Enter again.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Right-click on MyJPGFiles and select Properties from the popup menu. Leave all the settings as they are. Now enter the following commands in the &#8216;Target&#8217; field: Click Finish. Right-click on MyJPGFiles again and select Properties from the popup menu.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The dialog will now look similar to this: Click OK and then click Close. Select the desktop shortcut to MyJPGFiles and right-click it, choose Properties. Check the &#8216;Start In:&#8217; field, select your default folder (usually C:Program Files), click Apply, then click OK to close the properties window.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Now you can open JPG files with your new icon!<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Extracting the target file using VB<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">In this tutorial, we will show you how to extract the target file from a shortcut file. This can be useful if you want to use the shortcut file without the associated file.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">To start, open up a new VB project and create a new shortcut file. Right-click on the shortcut and select &#8216;Create Shortcut&#8217;. Name the shortcut &#8216;ExtractFile.lnk&#8217; and click on OK. Next, open up the &#8216;ExtractFile.lnk&#8217; shortcut in Visual Studio and add the following code:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Sub ExtractFile() &#8216; Extracts the target file from the shortcut Dim objShell As Shell Set objShell = CreateObject(&#8216;WScript.Shell&#8217;) Dim fso As Object Set fso = CreateObject(&#8216;Scripting.FileSystemObject&#8217;) Dim strPath As String strPath = Me.FullName If (InStr(1, strPath, &#8216;.lnk&#8217;)) &gt; 0 Then fso.CopyFile(Me.Clipboard, _ objShell.GetTempFolder &amp; &#8216;argetfile.txt&#8217;, True) Else MsgBox &#8216;The path to the .lnk file is not correct!&#8217; End If End Sub<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Next, right-click on the &#8216; ExtractFile&#8217; shortcut in the Visual Studio project. Select &#8216;Properties&#8217; from the menu. On the &#8216;Shortcut&#8217; tab, locate the Target field and click on it to select.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Add the following:Target: %ProgramFiles%Microsoft SDKsWindowsv7.1BINmspdbengine.exe<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This will tell Windows where your mspdbengine.exe is located so that MSBuild will be able to find it to process its build instructions contained within its manifest file.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Close the Properties window and return to Visual Studio if you haven&#8217;t already. Press F5 to compile your solution. (Note: If you don&#8217;t have a desktop with a shortcut on it, create one by right-clicking on the Visual Studio icon and choosing &#8216;Create Shortcut&#8217;.)<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">You should be able to now run the mspdbengine.exe from your application&#8217;s shortcut in Visual Studio.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How to extract the target file from a shortcut<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">In this tutorial, we will show you how to extract the target file from a shortcut. A shortcut is a file that contains the path to a program or document. When you double-click a shortcut, Windows takes you to the location where the shortcut was created. Sometimes, you may want to extract the target file from a shortcut.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">To do this, follow these steps:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">1. Right-click on the shortcut and select Properties from the menu.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">2. In the Properties dialog box, click on the Location tab.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">3. In the Location field, type the full path to the target file that you want to extract.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">4. Click on OK to save your changes and close the Properties dialog box.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">5. Right-click on the shortcut again and select Uninstall from the menu. The target file will be deleted from your computer.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">6. The installed shortcut will be removed from the Start menu and Control Panel. When you select a file that is part of a shortcut, Windows displays the contents of the shortcut in its default view mode (i.e., it shows all the shortcuts contained in the folder).<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Here&#8217;s a tutorial for using Visual Basic to extract the target file from a shortcut file. This is&#8230;<\/p>\n","protected":false},"author":6,"featured_media":192,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_kad_blocks_custom_css":"","_kad_blocks_head_custom_js":"","_kad_blocks_body_custom_js":"","_kad_blocks_footer_custom_js":"","_kadence_starter_templates_imported_post":false,"_kad_post_transparent":"","_kad_post_title":"","_kad_post_layout":"","_kad_post_sidebar_id":"","_kad_post_content_style":"","_kad_post_vertical_padding":"","_kad_post_feature":"","_kad_post_feature_position":"","_kad_post_header":false,"_kad_post_footer":false,"_kad_post_classname":"","footnotes":""},"categories":[116,4],"tags":[],"class_list":["post-163","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-extract-the-target-file-from-a-shortcut-file-lnk","category-tutorial"],"taxonomy_info":{"category":[{"value":116,"label":"Extract the target file from a shortcut file .lnk"},{"value":4,"label":"Tutorial"}]},"featured_image_src_large":["https:\/\/tutorialized.com\/wp-content\/uploads\/2022\/08\/visual-basic-extract-target-file-from-a-shortcut-file-1024x536.jpg",1024,536,true],"author_info":{"display_name":"Editor","author_link":"https:\/\/tutorialized.com\/author\/view\/"},"comment_info":8,"category_info":[{"term_id":116,"name":"Extract the target file from a shortcut file .lnk","slug":"extract-the-target-file-from-a-shortcut-file-lnk","term_group":0,"term_taxonomy_id":116,"taxonomy":"category","description":"","parent":4,"count":1,"filter":"raw","cat_ID":116,"category_count":1,"category_description":"","cat_name":"Extract the target file from a shortcut file .lnk","category_nicename":"extract-the-target-file-from-a-shortcut-file-lnk","category_parent":4},{"term_id":4,"name":"Tutorial","slug":"tutorial","term_group":0,"term_taxonomy_id":4,"taxonomy":"category","description":"","parent":0,"count":26,"filter":"raw","cat_ID":4,"category_count":26,"category_description":"","cat_name":"Tutorial","category_nicename":"tutorial","category_parent":0}],"tag_info":false,"_links":{"self":[{"href":"https:\/\/tutorialized.com\/wp-json\/wp\/v2\/posts\/163","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/tutorialized.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/tutorialized.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/tutorialized.com\/wp-json\/wp\/v2\/users\/6"}],"replies":[{"embeddable":true,"href":"https:\/\/tutorialized.com\/wp-json\/wp\/v2\/comments?post=163"}],"version-history":[{"count":3,"href":"https:\/\/tutorialized.com\/wp-json\/wp\/v2\/posts\/163\/revisions"}],"predecessor-version":[{"id":166,"href":"https:\/\/tutorialized.com\/wp-json\/wp\/v2\/posts\/163\/revisions\/166"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/tutorialized.com\/wp-json\/wp\/v2\/media\/192"}],"wp:attachment":[{"href":"https:\/\/tutorialized.com\/wp-json\/wp\/v2\/media?parent=163"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tutorialized.com\/wp-json\/wp\/v2\/categories?post=163"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tutorialized.com\/wp-json\/wp\/v2\/tags?post=163"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}