title: How do I create add a shortcut (.lnk) for my application to the Startup folder programatically in .NET/C#
body: <p>My application will have a per machine (not per user) Startup shortcut.  I can create a shortcut during the installer process no problem.  My problem comes when the user later removes it and then tries to re-enable.  In otherwords, they turn off RunOnStartup (which deletes the Startup ink) and at a later time they decide they do want it to run on startup so they go back into preferences and re-enable.    </p>
  
  <p>Apparently, this is a pretty common gripe with .NET that there isn't a native way to create shortcuts.  But, haven't found a very good solution.</p>
  
  <p>Solutions I've Found/Considered: </p>
  
  <ul>
  <li><p>Rather then create a shortcut.  Just copy one.  This might be a good solution.  I can't depend on there being a Start Menu link.  But, I guess I could probably create one and keep it in Program Directory... This shifts the problem over to my installer to have to create the shortcut with the appropriate path which would be specified at install time.  </p></li>
  <li><p>Do what <a href="https://stackoverflow.com/questions/234231/how-do-you-create-an-application-shortcut-lnk-file-in-c-or-net">this other stackoverflow answer</a> is and use a COM wrapper object.  I'd like to avoid COM.  It was also written in 2003.  So, I'm not sure how well it's going to support vista.  I'd give it a shot but don't have a vista box handy.  </p></li>
  <li><p>Use the registry instead.  This is how I currently do it... but run into issues on Vista.  It seems the general consensus that Startup Menu shortcuts are the proper way to do this so that's what my goal is.</p></li>
  </ul>
  
  <p>Also, I have to handle the case that a regular user (not an admin) tries to change this preference.  In this case, I need to gracefully fail or in the case of vista allow the user to enter the Admin password to get a Admin security token.  An answer which already properly takes into consider this case would be awesome.  </p>
  
  <p>I apologize if this topic has already been covered.  I searched around before posting. </p>
  
  <p><strong>UPDATE</strong>: Copying a shortcut which your installer created is the best solution.  I'll post code once finished... ran into some hurdles with a) Environment.GetSpecialFolder not having a reference to the StartMenu which has been resolved... But, now i'm dealing with elevating permissions to copy the file to the proper location.  I created a new stackoverflow question for this topic: <a href="https://stackoverflow.com/questions/1039875/how-can-i-copy-a-file-as-a-standard-user-in-vista-ie-an-administrative-choice">How can I copy a file as a &quot;Standard User&quot; in Vista (ie &quot;An Administrative Choice Application&quot;) by prompting user for admin credentials?</a></p>