How to add a shortcut (.lnk) file to your Visual Studio setup project 

Tags: .net, Programming, Visual Studio

Adding a shortcut is not as easy as you would expect in a Visual Studio setup project. To add a shortcut to the application's start menu you have to have a file already to the content. The only thing is that you cannot add a .lnk file to the setup project. I found the following KB article to add the .lnk file to my main project; http://support.microsoft.com/kb/837220. Okay, this works, but I still cannot add the files to the setup project unless I add the .lnk files as content, but checking the outputs of the content it includes many more files I do not need. Here is what I did to get shortcuts in my applications start menu.
 
1. Created a shortcut to my content in the main project's folder; in this case it was a web link. The shortcut path was "%programfiles%\Internet Explorer\iexplore.exe" www.chadschultz.com.
 
Image1
Image2
Image3
 
2. Went to my project and clicked Show All Files, as described in the KB article.
 
Image4
 
3. Renamed the .lnk file to .txt.
 
Image5
 
4. Added the .txt file to the setup project.
5. Renamed the .txt file back to .lnk.
 
Image6
 
6. Saved and closed Visual Studio.
7. Edited Setup.vdproj file in notepad.
8. Replaced the .txt for the shortcut to .lnk
9. Reopened Visual Studio. The .lnk files were listed in the setup project and could be used now in the File System Editor of the setup project to create a link in the applications start menu.
 
Chad
 
Posted by Chad on 9-Mar-09
0 Comments  |  Trackback Url  |  Link to this post | Bookmark this post with:        
 

Links to this post

Failed to render control: The operation being requested was not performed because the user has not been authenticated. (Exception from HRESULT: 0x800704DC)
Name:
URL:
Email:
Comments: