Solved

Creating a C# Installer Program with Visual Studio 2012

Posted on 2014-02-27
3
307 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 78

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Normally the drop down box control found in the .Net framework tools is able to select just one data and value at a time, which is displayed on the text area.   But what if you want to have multiple values to be selected in the drop down box? As …
Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

758 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now