Solved

Creating a C# Installer Program with Visual Studio 2012

Posted on 2014-02-27
3
309 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
  • 2
3 Comments
 
LVL 79

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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

773 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