Solved

Creating a C# Installer Program with Visual Studio 2012

Posted on 2014-02-27
3
311 Views
Last Modified: 2014-04-26
Hello, I am creating an installer program for Visual Studio 2012.  The program on it's own is simple enough, all I am doing is creating 10 icons that link to 10 different websites and I need the links to all be collectively put into a folder which will be found from the Start menu.  To give an example, here is a sample of what I am talking about but the only difference is the icons and website that it is linking to would be different:

Folder - Business Stuff
    1. Microsoft Icon(shortcut link) - links to Microsoft.com
    2. Google Icon(shortcut link) - links to Google.com
    3. Apple Icon(shortcut link) - links to Apple.com
    4. Yahoo Icon (shortcut link) - links to Yahoo.com
    5. Twitter Icon (shortcut link) - links to Twitter.com
    6. Facebook Icon (shortcut link) - links to Facebook.com
    7. Cnn.com Icon (shortcut link) - links to Cnn.com
   8. Msnbc.com Icon (shortcut link) - links to MSNBC.com
   9. Wikipedia.com Icon (shortcut link) - links to Wikipedia.com
  10. Instagram.com Icon (shortcut link) - links to Instagram.com

Each shortcut link will obviously be an .lnk file and when the user opens the folder in the Start Menu called Business Stuff, it will display all of the above links one on top of the other.  When you click on the link, it goes to the appropriate website listed above.  How could I create something like this in Visual Studio 2012?  Thanks!
0
Comment
Question by:VBBRett
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 80

Accepted Solution

by:
David Johnson, CD, MVP earned 500 total points
ID: 39893826
http://www.sorrowman.org/c-sharp-programmer/url-link-to-desktop.html
using System.IO;

private void urlShortcutToDesktop(string linkName, string linkUrl)
{
    string deskDir = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);

    using (StreamWriter writer = new StreamWriter(deskDir + "\\" + linkName + ".url"))
    {
        writer.WriteLine("[InternetShortcut]");
        writer.WriteLine("URL=" + linkUrl);
        writer.Flush();
    }
}

Open in new window


Now if you call it using something like this:

urlShortcutToDesktop("google link", "http://www.google.com/");

it should create shortcut in your desktop.
0
 

Author Comment

by:VBBRett
ID: 39908100
Thank you David, maybe if I could shed a little more light or detail on the subject.  I was told that the 10 programs above has to be consolidated into 1 program but I still need 10 icons.  So, as opposed to having this on the Desktop, it actually has to be in the Start Menu in a folder called "Business Services".  Inside the "Business Services" which is in the Start Menu, I would need all 10 icons to be available to be clicked on in this "Business Services" folder.  Each icon would be different and each icon would have to be linked to the appropriate sites above.  The program has to be able to be installed into Microsoft Windows using the Visual Studio InstallShield Wizard.  At the end of the game, this installshield program will be deployed to several desktop computers in the office.  Please tell me how I am to do this?  I have this as my code for one link, how could I have 10 links with a link for each icon?:

        static void Main(string[] args)
        {
           
            string target = "http://www.google.com";       
            
            
            try
            {
                
                System.Diagnostics.Process.Start(target);
            }
            catch (System.ComponentModel.Win32Exception noBrowser)
            {
                if (noBrowser.ErrorCode == -2147467259)
                    MessageBox.Show(noBrowser.Message);
            }
            catch (System.Exception other)
            {
                MessageBox.Show(other.Message);
            }                            

        }

Open in new window

0
 

Author Comment

by:VBBRett
ID: 39913725
How about this?

     public static void CreateShortcut(string shortcutname, string shortcutpath, string targetFileLocation)
        {
            string shortcutLocation = System.IO.Path.Combine(shortcutpath, shortcutname + ".lnk");
            WshShell shell = new WshShell();
            IWshShortcut shortcut = (IWshShortcut)shell.CreateShortcut(shortcutLocation);

            shortcut.Description = "My shortcut Description";
            shortcut.IconLocation = "MSN-Icon.ico";
            shortcut.TargetPath = "http://www.msn.com";
            shortcut.Save();
            
        }

Open in new window

0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Add a Condition in ASP Repeater 6 44
SSRS Deployment problem 5 91
Get sourcecode path 14 46
Powershell form - Anchor a button to a dynamically sized groupbox 2 42
Summary Displaying images in RichTextBox is a common requirement with limited solutions available. Pasting through clipboard or embedding into RTF content only support static images.  This article describes how to insert Windows control objects int…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

740 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question