Windows Develop Bookmark and Share   
 index > ClickOnce and Setup & Deployment Projects > Add menu items to ClickOnce Application
 

Add menu items to ClickOnce Application

How can I add start-menu items to the ClickOnce for additional tools I which I want to allow the user to use and also Uninstall item?

Eli Gazit  Wednesday, January 10, 2007 9:00 PM

I was looking for the same thing.

Did you ever get an answer?

DevDells  Thursday, June 19, 2008 7:45 PM

I have one trick.

1. Create a function for creating srart menu item for current user.

2. This function will check that if item are not their then it will create them.

3. Call this function in Main().

4. Deploy your application using clickonce.

You can always confirm you are running through ClickOnce using following code snip.

if (ApplicationDeployment.IsNetworkDeployed)

{

Your start menu Item creation code here.

}

Hope it will help

Thanks

AjitSingh1  Friday, June 20, 2008 1:40 PM
DevDells wrote:

I was looking for the same thing.

Did you ever get an answer?

Are you saying you want ClickOnce to install multiple applications that show up in the same folder in the Start Menu as the original application?

If so, you can deploy multiple applications to that folder by making sure they have the same Publisher name.

What exactly are you trying to do?

RobinS.

GoldMail.com

RobinDotNet  Tuesday, June 24, 2008 2:31 AM

I'm actually looking for an answer for that as well.

I tried it under the same publisher, but it doesn't work.

Assume I've got 2 different solution build by different developer, Sol A and Sol B.

If Sol B is preinstalled, and I were to run Sol A off the webpage, it actually rewrite the menu off to Sol A instead of concatenating extra Sol A into Sol B.

JustinWong  Tuesday, June 24, 2008 5:28 AM

Dang, I forgot to change the assembly name under application tab.

Now it works.

1. Make sure Sol A and Sol B under diff assembly name, off the application tab in your main project.

2. Both Sol A and Sol B should be under the same publisher name.

Cheers!

Jw

JustinWong  Tuesday, June 24, 2008 6:30 AM

I ended up going with an approach more like the first response suggests. But the whole shortcut thing is very compartmentalized towards setup projects. I used the VBscripting object instead because I was already used to that method. Now from my startup code I check for network deployed and IsFirstRun, then I install a desktop shortcut. (see code block below)

Justin's solution might work too, but in my case, I have a separate project under the same solution which is a shell for a form. The shell adds the form I want via dotnet reflection. The main app (published) is separate from the solution but I guess I could still try a separate 'publish' in the forms solution/project.

Code Snippet

Dim vsObj As New Object

vsObj = CreateObject("WScript.Shell")

Dim myShortcut As New Object

myShortcut = vsObj.createshortcut(vsObj.specialfolders("Desktop") & "/myNewShortcut.lnk")

myShortcut.targetpath = Path.Combine(Windows.Forms.Application.StartupPath, "myNewShortcut.exe")

myShortcut.save()

thanks to all for adding to this thread
DevDells  Tuesday, June 24, 2008 1:03 PM

Creating a shortcut the way you are doing it will not run the application as a ClickOnce application. So it won't check for updates, it won't check to see if the app is still valid, etc.

Here is code for creating a desktop application that will actually run the application as a ClickOnce app:

Code Snippet
/// <summary>
/// This will create a Application Reference file on the users desktop
/// if they do not already have one when the program is loaded.
/// Check for them running the deployed version before doing this,
/// so it doesn't kick it when you're running it from Visual Studio.
/// </summary
static void CheckForShortcut()
{
if (System.Deployment.Application.ApplicationDeployment.IsNetworkDeployed)
{
ApplicationDeployment ad = ApplicationDeployment.CurrentDeployment;
if (ad.IsFirstRun) //first time user has run the app
{
Assembly code = Assembly.GetExecutingAssembly();
string company = string.Empty;
string description = string.Empty;
if (Attribute.IsDefined(code, typeof(AssemblyCompanyAttribute)))
{
AssemblyCompanyAttribute ascompany =
(AssemblyCompanyAttribute)Attribute.GetCustomAttribute(code,
typeof(AssemblyCompanyAttribute));
company = ascompany.Company;
}
if (Attribute.IsDefined(code, typeof(AssemblyDescriptionAttribute)))
{
AssemblyDescriptionAttribute asdescription =
(AssemblyDescriptionAttribute)Attribute.GetCustomAttribute(code,
typeof(AssemblyDescriptionAttribute));
description = asdescription.Description;
}
if (company != string.Empty && description != string.Empty)
{
string desktopPath = string.Empty;
desktopPath =
string.Concat(Environment.GetFolderPath(Environment.SpecialFolder.Desktop),
"\\", description, ".appref-ms");
string shortcutName = string.Empty;
shortcutName =
string.Concat(Environment.GetFolderPath(Environment.SpecialFolder.Programs),
"\\", company, "\\", description, ".appref-ms");
System.IO.File.Copy(shortcutName, desktopPath,true);
}
}
}
}

I'm still not exactly sure what you're trying to do, so if you want more help, please try to clarify your intent.

RobinS.

GoldMail.com

RobinDotNet  Wednesday, June 25, 2008 4:11 AM

You can use google to search for other answers

Custom Search

More Threads

• During installation of a setup build in vs2005, what are the things happened in registry entry?
• Installing ClickOnce from MSI file and Let ClickOnce do the updates through program [if configured to do so]
• Problem uninstalling my windows service.
• dfsvc crash on limited user
• Jet Driver Launch Condition
• Can't start application
• could not find required file setup.bin at c:\..\bootstrapper\engine error
• Strong name signature not valid for this assembly Microsoft.mshtml.dll
• ClickOnce deployment â€?unable to automate that d*** thing
• Windows Control in IE, Problem Accessing Database, Strong Name doesn't seem to work