Solved

Creating a C# Installer Program with Visual Studio 2012

Posted on 2014-02-27
3
310 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 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: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying 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

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
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…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

840 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